home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libtypes.tex < prev    next >
LaTeX Document  |  1994-06-23  |  24.2 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libtypes.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 54 79 70 65 73 7d | 0d 0d 54 68 65 20 66 6f |n Types}|..The fo|
|00000020| 6c 6c 6f 77 69 6e 67 20 | 73 65 63 74 69 6f 6e 73 |llowing |sections|
|00000030| 20 64 65 73 63 72 69 62 | 65 20 74 68 65 20 73 74 | describ|e the st|
|00000040| 61 6e 64 61 72 64 20 74 | 79 70 65 73 20 74 68 61 |andard t|ypes tha|
|00000050| 74 20 61 72 65 20 62 75 | 69 6c 74 20 69 6e 74 6f |t are bu|ilt into|
|00000060| 0d 74 68 65 20 69 6e 74 | 65 72 70 72 65 74 65 72 |.the int|erpreter|
|00000070| 2e 20 20 54 68 65 73 65 | 20 61 72 65 20 74 68 65 |. These| are the|
|00000080| 20 6e 75 6d 65 72 69 63 | 20 74 79 70 65 73 2c 20 | numeric| types, |
|00000090| 73 65 71 75 65 6e 63 65 | 20 74 79 70 65 73 2c 20 |sequence| types, |
|000000a0| 61 6e 64 0d 73 65 76 65 | 72 61 6c 20 6f 74 68 65 |and.seve|ral othe|
|000000b0| 72 73 2c 20 69 6e 63 6c | 75 64 69 6e 67 20 74 79 |rs, incl|uding ty|
|000000c0| 70 65 73 20 74 68 65 6d | 73 65 6c 76 65 73 2e 20 |pes them|selves. |
|000000d0| 20 54 68 65 72 65 20 69 | 73 20 6e 6f 20 65 78 70 | There i|s no exp|
|000000e0| 6c 69 63 69 74 0d 42 6f | 6f 6c 65 61 6e 20 74 79 |licit.Bo|olean ty|
|000000f0| 70 65 3b 20 75 73 65 20 | 69 6e 74 65 67 65 72 73 |pe; use |integers|
|00000100| 20 69 6e 73 74 65 61 64 | 2e 0d 5c 69 6e 64 65 78 | instead|..\index|
|00000110| 69 69 7b 62 75 69 6c 74 | 2d 69 6e 7d 7b 74 79 70 |ii{built|-in}{typ|
|00000120| 65 73 7d 0d 5c 69 6e 64 | 65 78 69 69 7b 42 6f 6f |es}.\ind|exii{Boo|
|00000130| 6c 65 61 6e 7d 7b 74 79 | 70 65 7d 0d 0d 53 6f 6d |lean}{ty|pe}..Som|
|00000140| 65 20 6f 70 65 72 61 74 | 69 6f 6e 73 20 61 72 65 |e operat|ions are|
|00000150| 20 73 75 70 70 6f 72 74 | 65 64 20 62 79 20 73 65 | support|ed by se|
|00000160| 76 65 72 61 6c 20 6f 62 | 6a 65 63 74 20 74 79 70 |veral ob|ject typ|
|00000170| 65 73 3b 20 69 6e 20 70 | 61 72 74 69 63 75 6c 61 |es; in p|articula|
|00000180| 72 2c 0d 61 6c 6c 20 6f | 62 6a 65 63 74 73 20 63 |r,.all o|bjects c|
|00000190| 61 6e 20 62 65 20 63 6f | 6d 70 61 72 65 64 2c 20 |an be co|mpared, |
|000001a0| 74 65 73 74 65 64 20 66 | 6f 72 20 74 72 75 74 68 |tested f|or truth|
|000001b0| 20 76 61 6c 75 65 2c 20 | 61 6e 64 20 63 6f 6e 76 | value, |and conv|
|000001c0| 65 72 74 65 64 20 74 6f | 0d 61 20 73 74 72 69 6e |erted to|.a strin|
|000001d0| 67 20 28 77 69 74 68 20 | 74 68 65 20 5c 63 6f 64 |g (with |the \cod|
|000001e0| 65 7b 60 7b 5c 72 6d 20 | 5c 6c 64 6f 74 73 7d 60 |e{`{\rm |\ldots}`|
|000001f0| 7d 20 6e 6f 74 61 74 69 | 6f 6e 29 2e 20 20 54 68 |} notati|on). Th|
|00000200| 65 20 6c 61 74 74 65 72 | 20 63 6f 6e 76 65 72 73 |e latter| convers|
|00000210| 69 6f 6e 20 69 73 0d 69 | 6d 70 6c 69 63 69 74 6c |ion is.i|mplicitl|
|00000220| 79 20 75 73 65 64 20 77 | 68 65 6e 20 61 6e 20 6f |y used w|hen an o|
|00000230| 62 6a 65 63 74 20 69 73 | 20 77 72 69 74 74 65 6e |bject is| written|
|00000240| 20 62 79 20 74 68 65 20 | 5c 63 6f 64 65 7b 70 72 | by the |\code{pr|
|00000250| 69 6e 74 7d 20 73 74 61 | 74 65 6d 65 6e 74 2e 0d |int} sta|tement..|
|00000260| 5c 73 74 69 6e 64 65 78 | 7b 70 72 69 6e 74 7d 0d |\stindex|{print}.|
|00000270| 0d 5c 73 75 62 73 65 63 | 74 69 6f 6e 7b 54 72 75 |.\subsec|tion{Tru|
|00000280| 74 68 20 56 61 6c 75 65 | 20 54 65 73 74 69 6e 67 |th Value| Testing|
|00000290| 7d 0d 0d 41 6e 79 20 6f | 62 6a 65 63 74 20 63 61 |}..Any o|bject ca|
|000002a0| 6e 20 62 65 20 74 65 73 | 74 65 64 20 66 6f 72 20 |n be tes|ted for |
|000002b0| 74 72 75 74 68 20 76 61 | 6c 75 65 2c 20 66 6f 72 |truth va|lue, for|
|000002c0| 20 75 73 65 20 69 6e 20 | 61 6e 20 5c 63 6f 64 65 | use in |an \code|
|000002d0| 7b 69 66 7d 20 6f 72 0d | 5c 63 6f 64 65 7b 77 68 |{if} or.|\code{wh|
|000002e0| 69 6c 65 7d 20 63 6f 6e | 64 69 74 69 6f 6e 20 6f |ile} con|dition o|
|000002f0| 72 20 61 73 20 6f 70 65 | 72 61 6e 64 20 6f 66 20 |r as ope|rand of |
|00000300| 74 68 65 20 42 6f 6f 6c | 65 61 6e 20 6f 70 65 72 |the Bool|ean oper|
|00000310| 61 74 69 6f 6e 73 20 62 | 65 6c 6f 77 2e 0d 54 68 |ations b|elow..Th|
|00000320| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 76 61 6c 75 |e follow|ing valu|
|00000330| 65 73 20 61 72 65 20 66 | 61 6c 73 65 3a 0d 5c 73 |es are f|alse:.\s|
|00000340| 74 69 6e 64 65 78 7b 69 | 66 7d 0d 5c 73 74 69 6e |tindex{i|f}.\stin|
|00000350| 64 65 78 7b 77 68 69 6c | 65 7d 0d 5c 69 6e 64 65 |dex{whil|e}.\inde|
|00000360| 78 69 69 7b 74 72 75 74 | 68 7d 7b 76 61 6c 75 65 |xii{trut|h}{value|
|00000370| 7d 0d 5c 69 6e 64 65 78 | 69 69 7b 42 6f 6f 6c 65 |}.\index|ii{Boole|
|00000380| 61 6e 7d 7b 6f 70 65 72 | 61 74 69 6f 6e 73 7d 0d |an}{oper|ations}.|
|00000390| 5c 69 6e 64 65 78 7b 66 | 61 6c 73 65 7d 0d 0d 5c |\index{f|alse}..\|
|000003a0| 62 65 67 69 6e 7b 69 74 | 65 6d 69 7a 65 7d 0d 5c |begin{it|emize}.\|
|000003b0| 72 65 6e 65 77 63 6f 6d | 6d 61 6e 64 7b 5c 69 6e |renewcom|mand{\in|
|000003c0| 64 65 78 73 75 62 69 74 | 65 6d 7d 7b 28 42 75 69 |dexsubit|em}{(Bui|
|000003d0| 6c 74 2d 69 6e 20 6f 62 | 6a 65 63 74 29 7d 0d 0d |lt-in ob|ject)}..|
|000003e0| 5c 69 74 65 6d 09 5c 63 | 6f 64 65 7b 4e 6f 6e 65 |\item.\c|ode{None|
|000003f0| 7d 0d 09 5c 74 74 69 6e | 64 65 78 7b 4e 6f 6e 65 |}..\ttin|dex{None|
|00000400| 7d 0d 0d 5c 69 74 65 6d | 09 7a 65 72 6f 20 6f 66 |}..\item|.zero of|
|00000410| 20 61 6e 79 20 6e 75 6d | 65 72 69 63 20 74 79 70 | any num|eric typ|
|00000420| 65 2c 20 65 2e 67 2e 2c | 20 5c 63 6f 64 65 7b 30 |e, e.g.,| \code{0|
|00000430| 7d 2c 20 5c 63 6f 64 65 | 7b 30 4c 7d 2c 20 5c 63 |}, \code|{0L}, \c|
|00000440| 6f 64 65 7b 30 2e 30 7d | 2e 0d 0d 5c 69 74 65 6d |ode{0.0}|...\item|
|00000450| 09 61 6e 79 20 65 6d 70 | 74 79 20 73 65 71 75 65 |.any emp|ty seque|
|00000460| 6e 63 65 2c 20 65 2e 67 | 2e 2c 20 5c 63 6f 64 65 |nce, e.g|., \code|
|00000470| 7b 27 27 7d 2c 20 5c 63 | 6f 64 65 7b 28 29 7d 2c |{''}, \c|ode{()},|
|00000480| 20 5c 63 6f 64 65 7b 5b | 5d 7d 2e 0d 0d 5c 69 74 | \code{[|]}...\it|
|00000490| 65 6d 09 61 6e 79 20 65 | 6d 70 74 79 20 6d 61 70 |em.any e|mpty map|
|000004a0| 70 69 6e 67 2c 20 65 2e | 67 2e 2c 20 5c 63 6f 64 |ping, e.|g., \cod|
|000004b0| 65 7b 5c 7b 5c 7d 7d 2e | 0d 0d 5c 65 6e 64 7b 69 |e{\{\}}.|..\end{i|
|000004c0| 74 65 6d 69 7a 65 7d 0d | 0d 5c 65 6d 70 68 7b 41 |temize}.|.\emph{A|
|000004d0| 6c 6c 7d 20 6f 74 68 65 | 72 20 76 61 6c 75 65 73 |ll} othe|r values|
|000004e0| 20 61 72 65 20 74 72 75 | 65 20 2d 2d 2d 20 73 6f | are tru|e --- so|
|000004f0| 20 6f 62 6a 65 63 74 73 | 20 6f 66 20 6d 61 6e 79 | objects| of many|
|00000500| 20 74 79 70 65 73 20 61 | 72 65 0d 61 6c 77 61 79 | types a|re.alway|
|00000510| 73 20 74 72 75 65 2e 0d | 5c 69 6e 64 65 78 7b 74 |s true..|\index{t|
|00000520| 72 75 65 7d 0d 0d 5c 73 | 75 62 73 65 63 74 69 6f |rue}..\s|ubsectio|
|00000530| 6e 7b 42 6f 6f 6c 65 61 | 6e 20 4f 70 65 72 61 74 |n{Boolea|n Operat|
|00000540| 69 6f 6e 73 7d 0d 0d 54 | 68 65 73 65 20 61 72 65 |ions}..T|hese are|
|00000550| 20 74 68 65 20 42 6f 6f | 6c 65 61 6e 20 6f 70 65 | the Boo|lean ope|
|00000560| 72 61 74 69 6f 6e 73 3a | 0d 5c 69 6e 64 65 78 69 |rations:|.\indexi|
|00000570| 69 7b 42 6f 6f 6c 65 61 | 6e 7d 7b 6f 70 65 72 61 |i{Boolea|n}{opera|
|00000580| 74 69 6f 6e 73 7d 0d 0d | 5c 62 65 67 69 6e 7b 74 |tions}..|\begin{t|
|00000590| 61 62 6c 65 69 69 69 7d | 7b 7c 63 7c 6c 7c 63 7c |ableiii}|{|c|l|c||
|000005a0| 7d 7b 63 6f 64 65 7d 7b | 4f 70 65 72 61 74 69 6f |}{code}{|Operatio|
|000005b0| 6e 7d 7b 52 65 73 75 6c | 74 7d 7b 4e 6f 74 65 73 |n}{Resul|t}{Notes|
|000005c0| 7d 0d 20 20 5c 6c 69 6e | 65 69 69 69 7b 5c 76 61 |}. \lin|eiii{\va|
|000005d0| 72 7b 78 7d 20 6f 72 20 | 5c 76 61 72 7b 79 7d 7d |r{x} or |\var{y}}|
|000005e0| 7b 69 66 20 5c 76 61 72 | 7b 78 7d 20 69 73 20 66 |{if \var|{x} is f|
|000005f0| 61 6c 73 65 2c 20 74 68 | 65 6e 20 5c 76 61 72 7b |alse, th|en \var{|
|00000600| 79 7d 2c 20 65 6c 73 65 | 20 5c 76 61 72 7b 78 7d |y}, else| \var{x}|
|00000610| 7d 7b 28 31 29 7d 0d 20 | 20 5c 6c 69 6e 65 69 69 |}{(1)}. | \lineii|
|00000620| 69 7b 5c 76 61 72 7b 78 | 7d 20 61 6e 64 20 5c 76 |i{\var{x|} and \v|
|00000630| 61 72 7b 79 7d 7d 7b 69 | 66 20 5c 76 61 72 7b 78 |ar{y}}{i|f \var{x|
|00000640| 7d 20 69 73 20 66 61 6c | 73 65 2c 20 74 68 65 6e |} is fal|se, then|
|00000650| 20 5c 76 61 72 7b 78 7d | 2c 20 65 6c 73 65 20 5c | \var{x}|, else \|
|00000660| 76 61 72 7b 79 7d 7d 7b | 28 31 29 7d 0d 20 20 5c |var{y}}{|(1)}. \|
|00000670| 6c 69 6e 65 69 69 69 7b | 6e 6f 74 20 5c 76 61 72 |lineiii{|not \var|
|00000680| 7b 78 7d 7d 7b 69 66 20 | 5c 76 61 72 7b 78 7d 20 |{x}}{if |\var{x} |
|00000690| 69 73 20 66 61 6c 73 65 | 2c 20 74 68 65 6e 20 5c |is false|, then \|
|000006a0| 63 6f 64 65 7b 31 7d 2c | 20 65 6c 73 65 20 5c 63 |code{1},| else \c|
|000006b0| 6f 64 65 7b 30 7d 7d 7b | 7d 0d 5c 65 6e 64 7b 74 |ode{0}}{|}.\end{t|
|000006c0| 61 62 6c 65 69 69 69 7d | 0d 5c 6f 70 69 6e 64 65 |ableiii}|.\opinde|
|000006d0| 78 7b 61 6e 64 7d 0d 5c | 6f 70 69 6e 64 65 78 7b |x{and}.\|opindex{|
|000006e0| 6f 72 7d 0d 5c 6f 70 69 | 6e 64 65 78 7b 6e 6f 74 |or}.\opi|ndex{not|
|000006f0| 7d 0d 0d 5c 6e 6f 69 6e | 64 65 6e 74 0d 4e 6f 74 |}..\noin|dent.Not|
|00000700| 65 73 3a 0d 0d 5c 62 65 | 67 69 6e 7b 64 65 73 63 |es:..\be|gin{desc|
|00000710| 72 69 70 74 69 6f 6e 7d | 0d 0d 5c 69 74 65 6d 5b |ription}|..\item[|
|00000720| 28 31 29 5d 0d 54 68 65 | 73 65 20 6f 6e 6c 79 20 |(1)].The|se only |
|00000730| 65 76 61 6c 75 61 74 65 | 20 74 68 65 69 72 20 73 |evaluate| their s|
|00000740| 65 63 6f 6e 64 20 61 72 | 67 75 6d 65 6e 74 20 69 |econd ar|gument i|
|00000750| 66 20 6e 65 65 64 65 64 | 20 66 6f 72 20 74 68 65 |f needed| for the|
|00000760| 69 72 20 6f 75 74 63 6f | 6d 65 2e 0d 0d 5c 65 6e |ir outco|me...\en|
|00000770| 64 7b 64 65 73 63 72 69 | 70 74 69 6f 6e 7d 0d 0d |d{descri|ption}..|
|00000780| 5c 73 75 62 73 65 63 74 | 69 6f 6e 7b 43 6f 6d 70 |\subsect|ion{Comp|
|00000790| 61 72 69 73 6f 6e 73 7d | 0d 0d 43 6f 6d 70 61 72 |arisons}|..Compar|
|000007a0| 69 73 6f 6e 20 6f 70 65 | 72 61 74 69 6f 6e 73 20 |ison ope|rations |
|000007b0| 61 72 65 20 73 75 70 70 | 6f 72 74 65 64 20 62 79 |are supp|orted by|
|000007c0| 20 61 6c 6c 20 6f 62 6a | 65 63 74 73 3a 0d 0d 5c | all obj|ects:..\|
|000007d0| 62 65 67 69 6e 7b 74 61 | 62 6c 65 69 69 69 7d 7b |begin{ta|bleiii}{|
|000007e0| 7c 63 7c 6c 7c 63 7c 7d | 7b 63 6f 64 65 7d 7b 4f ||c|l|c|}|{code}{O|
|000007f0| 70 65 72 61 74 69 6f 6e | 7d 7b 4d 65 61 6e 69 6e |peration|}{Meanin|
|00000800| 67 7d 7b 4e 6f 74 65 73 | 7d 0d 20 20 5c 6c 69 6e |g}{Notes|}. \lin|
|00000810| 65 69 69 69 7b 3c 7d 7b | 73 74 72 69 63 74 6c 79 |eiii{<}{|strictly|
|00000820| 20 6c 65 73 73 20 74 68 | 61 6e 7d 7b 7d 0d 20 20 | less th|an}{}. |
|00000830| 5c 6c 69 6e 65 69 69 69 | 7b 3c 3d 7d 7b 6c 65 73 |\lineiii|{<=}{les|
|00000840| 73 20 74 68 61 6e 20 6f | 72 20 65 71 75 61 6c 7d |s than o|r equal}|
|00000850| 7b 7d 0d 20 20 5c 6c 69 | 6e 65 69 69 69 7b 3e 7d |{}. \li|neiii{>}|
|00000860| 7b 73 74 72 69 63 74 6c | 79 20 67 72 65 61 74 65 |{strictl|y greate|
|00000870| 72 20 74 68 61 6e 7d 7b | 7d 0d 20 20 5c 6c 69 6e |r than}{|}. \lin|
|00000880| 65 69 69 69 7b 3e 3d 7d | 7b 67 72 65 61 74 65 72 |eiii{>=}|{greater|
|00000890| 20 74 68 61 6e 20 6f 72 | 20 65 71 75 61 6c 7d 7b | than or| equal}{|
|000008a0| 7d 0d 20 20 5c 6c 69 6e | 65 69 69 69 7b 3d 3d 7d |}. \lin|eiii{==}|
|000008b0| 7b 65 71 75 61 6c 7d 7b | 7d 0d 20 20 5c 6c 69 6e |{equal}{|}. \lin|
|000008c0| 65 69 69 69 7b 3c 3e 7d | 7b 6e 6f 74 20 65 71 75 |eiii{<>}|{not equ|
|000008d0| 61 6c 7d 7b 28 31 29 7d | 0d 20 20 5c 6c 69 6e 65 |al}{(1)}|. \line|
|000008e0| 69 69 69 7b 21 3d 7d 7b | 6e 6f 74 20 65 71 75 61 |iii{!=}{|not equa|
|000008f0| 6c 7d 7b 28 31 29 7d 0d | 20 20 5c 6c 69 6e 65 69 |l}{(1)}.| \linei|
|00000900| 69 69 7b 69 73 7d 7b 6f | 62 6a 65 63 74 20 69 64 |ii{is}{o|bject id|
|00000910| 65 6e 74 69 74 79 7d 7b | 7d 0d 20 20 5c 6c 69 6e |entity}{|}. \lin|
|00000920| 65 69 69 69 7b 69 73 20 | 6e 6f 74 7d 7b 6e 65 67 |eiii{is |not}{neg|
|00000930| 61 74 65 64 20 6f 62 6a | 65 63 74 20 69 64 65 6e |ated obj|ect iden|
|00000940| 74 69 74 79 7d 7b 7d 0d | 5c 65 6e 64 7b 74 61 62 |tity}{}.|\end{tab|
|00000950| 6c 65 69 69 69 7d 0d 5c | 69 6e 64 65 78 69 69 7b |leiii}.\|indexii{|
|00000960| 6f 70 65 72 61 74 6f 72 | 7d 7b 63 6f 6d 70 61 72 |operator|}{compar|
|00000970| 69 73 6f 6e 7d 0d 5c 6f | 70 69 6e 64 65 78 7b 3d |ison}.\o|pindex{=|
|00000980| 3d 7d 20 25 20 58 58 58 | 20 2a 41 6c 6c 2a 20 6f |=} % XXX| *All* o|
|00000990| 74 68 65 72 73 20 68 61 | 76 65 20 66 75 6e 6e 79 |thers ha|ve funny|
|000009a0| 20 63 68 61 72 61 63 74 | 65 72 73 20 3c 20 21 20 | charact|ers < ! |
|000009b0| 3e 0d 5c 6f 70 69 6e 64 | 65 78 7b 69 73 7d 0d 5c |>.\opind|ex{is}.\|
|000009c0| 6f 70 69 6e 64 65 78 7b | 69 73 20 6e 6f 74 7d 0d |opindex{|is not}.|
|000009d0| 0d 5c 6e 6f 69 6e 64 65 | 6e 74 0d 4e 6f 74 65 73 |.\noinde|nt.Notes|
|000009e0| 3a 0d 0d 5c 62 65 67 69 | 6e 7b 64 65 73 63 72 69 |:..\begi|n{descri|
|000009f0| 70 74 69 6f 6e 7d 0d 0d | 5c 69 74 65 6d 5b 28 31 |ption}..|\item[(1|
|00000a00| 29 5d 0d 5c 63 6f 64 65 | 7b 3c 3e 7d 20 61 6e 64 |)].\code|{<>} and|
|00000a10| 20 5c 63 6f 64 65 7b 21 | 3d 7d 20 61 72 65 20 61 | \code{!|=} are a|
|00000a20| 6c 74 65 72 6e 61 74 65 | 20 73 70 65 6c 6c 69 6e |lternate| spellin|
|00000a30| 67 73 20 66 6f 72 20 74 | 68 65 20 73 61 6d 65 20 |gs for t|he same |
|00000a40| 6f 70 65 72 61 74 6f 72 | 2e 0d 28 49 20 63 6f 75 |operator|..(I cou|
|00000a50| 6c 64 6e 27 74 20 63 68 | 6f 6f 73 65 20 62 65 74 |ldn't ch|oose bet|
|00000a60| 77 65 65 6e 20 5c 41 42 | 43 7b 7d 20 61 6e 64 20 |ween \AB|C{} and |
|00000a70| 5c 43 7b 7d 21 20 3a 2d | 29 0d 5c 69 6e 64 65 78 |\C{}! :-|).\index|
|00000a80| 69 69 7b 5c 41 42 43 7b | 7d 7d 7b 6c 61 6e 67 75 |ii{\ABC{|}}{langu|
|00000a90| 61 67 65 7d 0d 5c 69 6e | 64 65 78 69 69 7b 5c 43 |age}.\in|dexii{\C|
|00000aa0| 7b 7d 7d 7b 6c 61 6e 67 | 75 61 67 65 7d 0d 0d 5c |{}}{lang|uage}..\|
|00000ab0| 65 6e 64 7b 64 65 73 63 | 72 69 70 74 69 6f 6e 7d |end{desc|ription}|
|00000ac0| 0d 0d 4f 62 6a 65 63 74 | 73 20 6f 66 20 64 69 66 |..Object|s of dif|
|00000ad0| 66 65 72 65 6e 74 20 74 | 79 70 65 73 2c 20 65 78 |ferent t|ypes, ex|
|00000ae0| 63 65 70 74 20 64 69 66 | 66 65 72 65 6e 74 20 6e |cept dif|ferent n|
|00000af0| 75 6d 65 72 69 63 20 74 | 79 70 65 73 2c 20 6e 65 |umeric t|ypes, ne|
|00000b00| 76 65 72 0d 63 6f 6d 70 | 61 72 65 20 65 71 75 61 |ver.comp|are equa|
|00000b10| 6c 3b 20 73 75 63 68 20 | 6f 62 6a 65 63 74 73 20 |l; such |objects |
|00000b20| 61 72 65 20 6f 72 64 65 | 72 65 64 20 63 6f 6e 73 |are orde|red cons|
|00000b30| 69 73 74 65 6e 74 6c 79 | 20 62 75 74 20 61 72 62 |istently| but arb|
|00000b40| 69 74 72 61 72 69 6c 79 | 0d 28 73 6f 20 74 68 61 |itrarily|.(so tha|
|00000b50| 74 20 73 6f 72 74 69 6e | 67 20 61 20 68 65 74 65 |t sortin|g a hete|
|00000b60| 72 6f 67 65 6e 65 6f 75 | 73 20 61 72 72 61 79 20 |rogeneou|s array |
|00000b70| 79 69 65 6c 64 73 20 61 | 20 63 6f 6e 73 69 73 74 |yields a| consist|
|00000b80| 65 6e 74 20 72 65 73 75 | 6c 74 29 2e 0d 46 75 72 |ent resu|lt)..Fur|
|00000b90| 74 68 65 72 6d 6f 72 65 | 2c 20 73 6f 6d 65 20 74 |thermore|, some t|
|00000ba0| 79 70 65 73 20 28 65 2e | 67 2e 2c 20 77 69 6e 64 |ypes (e.|g., wind|
|00000bb0| 6f 77 73 29 20 73 75 70 | 70 6f 72 74 20 6f 6e 6c |ows) sup|port onl|
|00000bc0| 79 20 61 20 64 65 67 65 | 6e 65 72 61 74 65 0d 6e |y a dege|nerate.n|
|00000bd0| 6f 74 69 6f 6e 20 6f 66 | 20 63 6f 6d 70 61 72 69 |otion of| compari|
|00000be0| 73 6f 6e 20 77 68 65 72 | 65 20 61 6e 79 20 74 77 |son wher|e any tw|
|00000bf0| 6f 20 6f 62 6a 65 63 74 | 73 20 6f 66 20 74 68 61 |o object|s of tha|
|00000c00| 74 20 74 79 70 65 20 61 | 72 65 20 75 6e 65 71 75 |t type a|re unequ|
|00000c10| 61 6c 2e 0d 41 67 61 69 | 6e 2c 20 73 75 63 68 20 |al..Agai|n, such |
|00000c20| 6f 62 6a 65 63 74 73 20 | 61 72 65 20 6f 72 64 65 |objects |are orde|
|00000c30| 72 65 64 20 61 72 62 69 | 74 72 61 72 69 6c 79 20 |red arbi|trarily |
|00000c40| 62 75 74 20 63 6f 6e 73 | 69 73 74 65 6e 74 6c 79 |but cons|istently|
|00000c50| 2e 0d 5c 69 6e 64 65 78 | 69 69 7b 74 79 70 65 73 |..\index|ii{types|
|00000c60| 7d 7b 6e 75 6d 65 72 69 | 63 7d 0d 5c 69 6e 64 65 |}{numeri|c}.\inde|
|00000c70| 78 69 69 7b 6f 62 6a 65 | 63 74 73 7d 7b 63 6f 6d |xii{obje|cts}{com|
|00000c80| 70 61 72 69 6e 67 7d 0d | 0d 28 49 6d 70 6c 65 6d |paring}.|.(Implem|
|00000c90| 65 6e 74 61 74 69 6f 6e | 20 6e 6f 74 65 3a 20 6f |entation| note: o|
|00000ca0| 62 6a 65 63 74 73 20 6f | 66 20 64 69 66 66 65 72 |bjects o|f differ|
|00000cb0| 65 6e 74 20 74 79 70 65 | 73 20 65 78 63 65 70 74 |ent type|s except|
|00000cc0| 20 6e 75 6d 62 65 72 73 | 20 61 72 65 0d 6f 72 64 | numbers| are.ord|
|00000cd0| 65 72 65 64 20 62 79 20 | 74 68 65 69 72 20 74 79 |ered by |their ty|
|00000ce0| 70 65 20 6e 61 6d 65 73 | 3b 20 6f 62 6a 65 63 74 |pe names|; object|
|00000cf0| 73 20 6f 66 20 74 68 65 | 20 73 61 6d 65 20 74 79 |s of the| same ty|
|00000d00| 70 65 73 20 74 68 61 74 | 20 64 6f 6e 27 74 0d 73 |pes that| don't.s|
|00000d10| 75 70 70 6f 72 74 20 70 | 72 6f 70 65 72 20 63 6f |upport p|roper co|
|00000d20| 6d 70 61 72 69 73 6f 6e | 20 61 72 65 20 6f 72 64 |mparison| are ord|
|00000d30| 65 72 65 64 20 62 79 20 | 74 68 65 69 72 20 61 64 |ered by |their ad|
|00000d40| 64 72 65 73 73 2e 29 0d | 0d 54 77 6f 20 6d 6f 72 |dress.).|.Two mor|
|00000d50| 65 20 6f 70 65 72 61 74 | 69 6f 6e 73 20 77 69 74 |e operat|ions wit|
|00000d60| 68 20 74 68 65 20 73 61 | 6d 65 20 73 79 6e 74 61 |h the sa|me synta|
|00000d70| 63 74 69 63 20 70 72 69 | 6f 72 69 74 79 2c 20 5c |ctic pri|ority, \|
|00000d80| 63 6f 64 65 7b 69 6e 7d | 20 61 6e 64 0d 5c 63 6f |code{in}| and.\co|
|00000d90| 64 65 7b 6e 6f 74 20 69 | 6e 7d 2c 20 61 72 65 20 |de{not i|n}, are |
|00000da0| 73 75 70 70 6f 72 74 65 | 64 20 6f 6e 6c 79 20 62 |supporte|d only b|
|00000db0| 79 20 73 65 71 75 65 6e | 63 65 20 74 79 70 65 73 |y sequen|ce types|
|00000dc0| 20 28 62 65 6c 6f 77 29 | 2e 0d 5c 6f 70 69 6e 64 | (below)|..\opind|
|00000dd0| 65 78 7b 69 6e 7d 0d 5c | 6f 70 69 6e 64 65 78 7b |ex{in}.\|opindex{|
|00000de0| 6e 6f 74 20 69 6e 7d 0d | 0d 5c 73 75 62 73 65 63 |not in}.|.\subsec|
|00000df0| 74 69 6f 6e 7b 4e 75 6d | 65 72 69 63 20 54 79 70 |tion{Num|eric Typ|
|00000e00| 65 73 7d 0d 0d 54 68 65 | 72 65 20 61 72 65 20 74 |es}..The|re are t|
|00000e10| 68 72 65 65 20 6e 75 6d | 65 72 69 63 20 74 79 70 |hree num|eric typ|
|00000e20| 65 73 3a 20 5c 64 66 6e | 7b 70 6c 61 69 6e 20 69 |es: \dfn|{plain i|
|00000e30| 6e 74 65 67 65 72 73 7d | 2c 20 5c 64 66 6e 7b 6c |ntegers}|, \dfn{l|
|00000e40| 6f 6e 67 20 69 6e 74 65 | 67 65 72 73 7d 2c 20 61 |ong inte|gers}, a|
|00000e50| 6e 64 0d 5c 64 66 6e 7b | 66 6c 6f 61 74 69 6e 67 |nd.\dfn{|floating|
|00000e60| 20 70 6f 69 6e 74 20 6e | 75 6d 62 65 72 73 7d 2e | point n|umbers}.|
|00000e70| 20 20 50 6c 61 69 6e 20 | 69 6e 74 65 67 65 72 73 | Plain |integers|
|00000e80| 20 28 61 6c 73 6f 20 6a | 75 73 74 20 63 61 6c 6c | (also j|ust call|
|00000e90| 65 64 20 5c 64 66 6e 7b | 69 6e 74 65 67 65 72 73 |ed \dfn{|integers|
|00000ea0| 7d 29 0d 61 72 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |}).are i|mplement|
|00000eb0| 65 64 20 75 73 69 6e 67 | 20 5c 63 6f 64 65 7b 6c |ed using| \code{l|
|00000ec0| 6f 6e 67 7d 20 69 6e 20 | 5c 43 7b 7d 2c 20 77 68 |ong} in |\C{}, wh|
|00000ed0| 69 63 68 20 67 69 76 65 | 73 20 74 68 65 6d 20 61 |ich give|s them a|
|00000ee0| 74 20 6c 65 61 73 74 20 | 33 32 0d 62 69 74 73 20 |t least |32.bits |
|00000ef0| 6f 66 20 70 72 65 63 69 | 73 69 6f 6e 2e 20 20 4c |of preci|sion. L|
|00000f00| 6f 6e 67 20 69 6e 74 65 | 67 65 72 73 20 68 61 76 |ong inte|gers hav|
|00000f10| 65 20 75 6e 6c 69 6d 69 | 74 65 64 20 70 72 65 63 |e unlimi|ted prec|
|00000f20| 69 73 69 6f 6e 2e 20 20 | 46 6c 6f 61 74 69 6e 67 |ision. |Floating|
|00000f30| 0d 70 6f 69 6e 74 20 6e | 75 6d 62 65 72 73 20 61 |.point n|umbers a|
|00000f40| 72 65 20 69 6d 70 6c 65 | 6d 65 6e 74 65 64 20 75 |re imple|mented u|
|00000f50| 73 69 6e 67 20 5c 63 6f | 64 65 7b 64 6f 75 62 6c |sing \co|de{doubl|
|00000f60| 65 7d 20 69 6e 20 5c 43 | 7b 7d 2e 20 20 41 6c 6c |e} in \C|{}. All|
|00000f70| 20 62 65 74 73 20 6f 6e | 0d 74 68 65 69 72 20 70 | bets on|.their p|
|00000f80| 72 65 63 69 73 69 6f 6e | 20 61 72 65 20 6f 66 66 |recision| are off|
|00000f90| 20 75 6e 6c 65 73 73 20 | 79 6f 75 20 68 61 70 70 | unless |you happ|
|00000fa0| 65 6e 20 74 6f 20 6b 6e | 6f 77 20 74 68 65 20 6d |en to kn|ow the m|
|00000fb0| 61 63 68 69 6e 65 20 79 | 6f 75 20 61 72 65 0d 77 |achine y|ou are.w|
|00000fc0| 6f 72 6b 69 6e 67 20 77 | 69 74 68 2e 0d 5c 69 6e |orking w|ith..\in|
|00000fd0| 64 65 78 69 69 7b 6e 75 | 6d 65 72 69 63 7d 7b 74 |dexii{nu|meric}{t|
|00000fe0| 79 70 65 73 7d 0d 5c 69 | 6e 64 65 78 69 69 7b 69 |ypes}.\i|ndexii{i|
|00000ff0| 6e 74 65 67 65 72 7d 7b | 74 79 70 65 73 7d 0d 5c |nteger}{|types}.\|
|00001000| 69 6e 64 65 78 69 69 7b | 69 6e 74 65 67 65 72 7d |indexii{|integer}|
|00001010| 7b 74 79 70 65 7d 0d 5c | 69 6e 64 65 78 69 69 69 |{type}.\|indexiii|
|00001020| 7b 6c 6f 6e 67 7d 7b 69 | 6e 74 65 67 65 72 7d 7b |{long}{i|nteger}{|
|00001030| 74 79 70 65 7d 0d 5c 69 | 6e 64 65 78 69 69 7b 66 |type}.\i|ndexii{f|
|00001040| 6c 6f 61 74 69 6e 67 20 | 70 6f 69 6e 74 7d 7b 74 |loating |point}{t|
|00001050| 79 70 65 7d 0d 5c 69 6e | 64 65 78 69 69 7b 5c 43 |ype}.\in|dexii{\C|
|00001060| 7b 7d 7d 7b 6c 61 6e 67 | 75 61 67 65 7d 0d 0d 4e |{}}{lang|uage}..N|
|00001070| 75 6d 62 65 72 73 20 61 | 72 65 20 63 72 65 61 74 |umbers a|re creat|
|00001080| 65 64 20 62 79 20 6e 75 | 6d 65 72 69 63 20 6c 69 |ed by nu|meric li|
|00001090| 74 65 72 61 6c 73 20 6f | 72 20 61 73 20 74 68 65 |terals o|r as the|
|000010a0| 20 72 65 73 75 6c 74 20 | 6f 66 20 62 75 69 6c 74 | result |of built|
|000010b0| 2d 69 6e 0d 66 75 6e 63 | 74 69 6f 6e 73 20 61 6e |-in.func|tions an|
|000010c0| 64 20 6f 70 65 72 61 74 | 6f 72 73 2e 20 20 55 6e |d operat|ors. Un|
|000010d0| 61 64 6f 72 6e 65 64 20 | 69 6e 74 65 67 65 72 20 |adorned |integer |
|000010e0| 6c 69 74 65 72 61 6c 73 | 20 28 69 6e 63 6c 75 64 |literals| (includ|
|000010f0| 69 6e 67 20 68 65 78 0d | 61 6e 64 20 6f 63 74 61 |ing hex.|and octa|
|00001100| 6c 20 6e 75 6d 62 65 72 | 73 29 20 79 69 65 6c 64 |l number|s) yield|
|00001110| 20 70 6c 61 69 6e 20 69 | 6e 74 65 67 65 72 73 2e | plain i|ntegers.|
|00001120| 20 20 49 6e 74 65 67 65 | 72 20 6c 69 74 65 72 61 | Intege|r litera|
|00001130| 6c 73 20 77 69 74 68 20 | 61 6e 20 5c 73 61 6d 70 |ls with |an \samp|
|00001140| 7b 4c 7d 0d 6f 72 20 5c | 73 61 6d 70 7b 6c 7d 20 |{L}.or \|samp{l} |
|00001150| 73 75 66 66 69 78 20 79 | 69 65 6c 64 20 6c 6f 6e |suffix y|ield lon|
|00001160| 67 20 69 6e 74 65 67 65 | 72 73 0d 28 5c 73 61 6d |g intege|rs.(\sam|
|00001170| 70 7b 4c 7d 20 69 73 20 | 70 72 65 66 65 72 72 65 |p{L} is |preferre|
|00001180| 64 20 62 65 63 61 75 73 | 65 20 5c 63 6f 64 65 7b |d becaus|e \code{|
|00001190| 31 6c 7d 20 6c 6f 6f 6b | 73 20 74 6f 6f 20 6d 75 |1l} look|s too mu|
|000011a0| 63 68 20 6c 69 6b 65 20 | 65 6c 65 76 65 6e 21 29 |ch like |eleven!)|
|000011b0| 2e 0d 4e 75 6d 65 72 69 | 63 20 6c 69 74 65 72 61 |..Numeri|c litera|
|000011c0| 6c 73 20 63 6f 6e 74 61 | 69 6e 69 6e 67 20 61 20 |ls conta|ining a |
|000011d0| 64 65 63 69 6d 61 6c 20 | 70 6f 69 6e 74 20 6f 72 |decimal |point or|
|000011e0| 20 61 6e 20 65 78 70 6f | 6e 65 6e 74 20 73 69 67 | an expo|nent sig|
|000011f0| 6e 20 79 69 65 6c 64 0d | 66 6c 6f 61 74 69 6e 67 |n yield.|floating|
|00001200| 20 70 6f 69 6e 74 20 6e | 75 6d 62 65 72 73 2e 0d | point n|umbers..|
|00001210| 5c 69 6e 64 65 78 69 69 | 7b 6e 75 6d 65 72 69 63 |\indexii|{numeric|
|00001220| 7d 7b 6c 69 74 65 72 61 | 6c 73 7d 0d 5c 69 6e 64 |}{litera|ls}.\ind|
|00001230| 65 78 69 69 7b 69 6e 74 | 65 67 65 72 7d 7b 6c 69 |exii{int|eger}{li|
|00001240| 74 65 72 61 6c 73 7d 0d | 5c 69 6e 64 65 78 69 69 |terals}.|\indexii|
|00001250| 69 7b 6c 6f 6e 67 7d 7b | 69 6e 74 65 67 65 72 7d |i{long}{|integer}|
|00001260| 7b 6c 69 74 65 72 61 6c | 73 7d 0d 5c 69 6e 64 65 |{literal|s}.\inde|
|00001270| 78 69 69 7b 66 6c 6f 61 | 74 69 6e 67 20 70 6f 69 |xii{floa|ting poi|
|00001280| 6e 74 7d 7b 6c 69 74 65 | 72 61 6c 73 7d 0d 5c 69 |nt}{lite|rals}.\i|
|00001290| 6e 64 65 78 69 69 7b 68 | 65 78 61 64 65 63 69 6d |ndexii{h|exadecim|
|000012a0| 61 6c 7d 7b 6c 69 74 65 | 72 61 6c 73 7d 0d 5c 69 |al}{lite|rals}.\i|
|000012b0| 6e 64 65 78 69 69 7b 6f | 63 74 61 6c 7d 7b 6c 69 |ndexii{o|ctal}{li|
|000012c0| 74 65 72 61 6c 73 7d 0d | 0d 50 79 74 68 6f 6e 20 |terals}.|.Python |
|000012d0| 66 75 6c 6c 79 20 73 75 | 70 70 6f 72 74 73 20 6d |fully su|pports m|
|000012e0| 69 78 65 64 20 61 72 69 | 74 68 6d 65 74 69 63 3a |ixed ari|thmetic:|
|000012f0| 20 77 68 65 6e 20 61 20 | 62 69 6e 61 72 79 20 61 | when a |binary a|
|00001300| 72 69 74 68 6d 65 74 69 | 63 0d 6f 70 65 72 61 74 |rithmeti|c.operat|
|00001310| 6f 72 20 68 61 73 20 6f | 70 65 72 61 6e 64 73 20 |or has o|perands |
|00001320| 6f 66 20 64 69 66 66 65 | 72 65 6e 74 20 6e 75 6d |of diffe|rent num|
|00001330| 65 72 69 63 20 74 79 70 | 65 73 2c 20 74 68 65 20 |eric typ|es, the |
|00001340| 6f 70 65 72 61 6e 64 20 | 77 69 74 68 20 74 68 65 |operand |with the|
|00001350| 0d 60 60 73 6d 61 6c 6c | 65 72 27 27 20 74 79 70 |.``small|er'' typ|
|00001360| 65 20 69 73 20 63 6f 6e | 76 65 72 74 65 64 20 74 |e is con|verted t|
|00001370| 6f 20 74 68 61 74 20 6f | 66 20 74 68 65 20 6f 74 |o that o|f the ot|
|00001380| 68 65 72 2c 20 77 68 65 | 72 65 20 70 6c 61 69 6e |her, whe|re plain|
|00001390| 0d 69 6e 74 65 67 65 72 | 20 69 73 20 73 6d 61 6c |.integer| is smal|
|000013a0| 6c 65 72 20 74 68 61 6e | 20 6c 6f 6e 67 20 69 6e |ler than| long in|
|000013b0| 74 65 67 65 72 20 69 73 | 20 73 6d 61 6c 6c 65 72 |teger is| smaller|
|000013c0| 20 74 68 61 6e 20 66 6c | 6f 61 74 69 6e 67 20 70 | than fl|oating p|
|000013d0| 6f 69 6e 74 2e 0d 43 6f | 6d 70 61 72 69 73 6f 6e |oint..Co|mparison|
|000013e0| 73 20 62 65 74 77 65 65 | 6e 20 6e 75 6d 62 65 72 |s betwee|n number|
|000013f0| 73 20 6f 66 20 6d 69 78 | 65 64 20 74 79 70 65 20 |s of mix|ed type |
|00001400| 75 73 65 20 74 68 65 20 | 73 61 6d 65 20 72 75 6c |use the |same rul|
|00001410| 65 2e 25 0d 5c 66 6f 6f | 74 6e 6f 74 65 7b 41 73 |e.%.\foo|tnote{As|
|00001420| 20 61 20 63 6f 6e 73 65 | 71 75 65 6e 63 65 2c 20 | a conse|quence, |
|00001430| 74 68 65 20 6c 69 73 74 | 20 5c 63 6f 64 65 7b 5b |the list| \code{[|
|00001440| 31 2c 20 32 5d 7d 20 69 | 73 20 63 6f 6e 73 69 64 |1, 2]} i|s consid|
|00001450| 65 72 65 64 20 65 71 75 | 61 6c 0d 09 74 6f 20 5c |ered equ|al..to \|
|00001460| 63 6f 64 65 7b 5b 31 2e | 30 2c 20 32 2e 30 5d 7d |code{[1.|0, 2.0]}|
|00001470| 2c 20 61 6e 64 20 73 69 | 6d 69 6c 61 72 20 66 6f |, and si|milar fo|
|00001480| 72 20 74 75 70 6c 65 73 | 2e 7d 0d 54 68 65 20 66 |r tuples|.}.The f|
|00001490| 75 6e 63 74 69 6f 6e 73 | 20 5c 63 6f 64 65 7b 69 |unctions| \code{i|
|000014a0| 6e 74 28 29 7d 2c 20 5c | 63 6f 64 65 7b 6c 6f 6e |nt()}, \|code{lon|
|000014b0| 67 28 29 7d 20 61 6e 64 | 20 5c 63 6f 64 65 7b 66 |g()} and| \code{f|
|000014c0| 6c 6f 61 74 28 29 7d 20 | 63 61 6e 20 62 65 20 75 |loat()} |can be u|
|000014d0| 73 65 64 0d 74 6f 20 63 | 6f 65 72 63 65 20 6e 75 |sed.to c|oerce nu|
|000014e0| 6d 62 65 72 73 20 74 6f | 20 61 20 73 70 65 63 69 |mbers to| a speci|
|000014f0| 66 69 63 20 74 79 70 65 | 2e 0d 5c 69 6e 64 65 78 |fic type|..\index|
|00001500| 7b 61 72 69 74 68 6d 65 | 74 69 63 7d 0d 5c 62 69 |{arithme|tic}.\bi|
|00001510| 66 75 6e 63 69 6e 64 65 | 78 7b 69 6e 74 7d 0d 5c |funcinde|x{int}.\|
|00001520| 62 69 66 75 6e 63 69 6e | 64 65 78 7b 6c 6f 6e 67 |bifuncin|dex{long|
|00001530| 7d 0d 5c 62 69 66 75 6e | 63 69 6e 64 65 78 7b 66 |}.\bifun|cindex{f|
|00001540| 6c 6f 61 74 7d 0d 0d 41 | 6c 6c 20 6e 75 6d 65 72 |loat}..A|ll numer|
|00001550| 69 63 20 74 79 70 65 73 | 20 73 75 70 70 6f 72 74 |ic types| support|
|00001560| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 6f | the fol|lowing o|
|00001570| 70 65 72 61 74 69 6f 6e | 73 3a 0d 0d 5c 62 65 67 |peration|s:..\beg|
|00001580| 69 6e 7b 74 61 62 6c 65 | 69 69 69 7d 7b 7c 63 7c |in{table|iii}{|c||
|00001590| 6c 7c 63 7c 7d 7b 63 6f | 64 65 7d 7b 4f 70 65 72 |l|c|}{co|de}{Oper|
|000015a0| 61 74 69 6f 6e 7d 7b 52 | 65 73 75 6c 74 7d 7b 4e |ation}{R|esult}{N|
|000015b0| 6f 74 65 73 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |otes}. |\lineiii|
|000015c0| 7b 61 62 73 28 5c 76 61 | 72 7b 78 7d 29 7d 7b 61 |{abs(\va|r{x})}{a|
|000015d0| 62 73 6f 6c 75 74 65 20 | 76 61 6c 75 65 20 6f 66 |bsolute |value of|
|000015e0| 20 5c 76 61 72 7b 78 7d | 7d 7b 7d 0d 20 20 5c 6c | \var{x}|}{}. \l|
|000015f0| 69 6e 65 69 69 69 7b 69 | 6e 74 28 5c 76 61 72 7b |ineiii{i|nt(\var{|
|00001600| 78 7d 29 7d 7b 5c 76 61 | 72 7b 78 7d 20 63 6f 6e |x})}{\va|r{x} con|
|00001610| 76 65 72 74 65 64 20 74 | 6f 20 69 6e 74 65 67 65 |verted t|o intege|
|00001620| 72 7d 7b 28 31 29 7d 0d | 20 20 5c 6c 69 6e 65 69 |r}{(1)}.| \linei|
|00001630| 69 69 7b 6c 6f 6e 67 28 | 5c 76 61 72 7b 78 7d 29 |ii{long(|\var{x})|
|00001640| 7d 7b 5c 76 61 72 7b 78 | 7d 20 63 6f 6e 76 65 72 |}{\var{x|} conver|
|00001650| 74 65 64 20 74 6f 20 6c | 6f 6e 67 20 69 6e 74 65 |ted to l|ong inte|
|00001660| 67 65 72 7d 7b 28 31 29 | 7d 0d 20 20 5c 6c 69 6e |ger}{(1)|}. \lin|
|00001670| 65 69 69 69 7b 66 6c 6f | 61 74 28 5c 76 61 72 7b |eiii{flo|at(\var{|
|00001680| 78 7d 29 7d 7b 5c 76 61 | 72 7b 78 7d 20 63 6f 6e |x})}{\va|r{x} con|
|00001690| 76 65 72 74 65 64 20 74 | 6f 20 66 6c 6f 61 74 69 |verted t|o floati|
|000016a0| 6e 67 20 70 6f 69 6e 74 | 7d 7b 7d 0d 20 20 5c 6c |ng point|}{}. \l|
|000016b0| 69 6e 65 69 69 69 7b 2d | 5c 76 61 72 7b 78 7d 7d |ineiii{-|\var{x}}|
|000016c0| 7b 5c 76 61 72 7b 78 7d | 20 6e 65 67 61 74 65 64 |{\var{x}| negated|
|000016d0| 7d 7b 7d 0d 20 20 5c 6c | 69 6e 65 69 69 69 7b 2b |}{}. \l|ineiii{+|
|000016e0| 5c 76 61 72 7b 78 7d 7d | 7b 5c 76 61 72 7b 78 7d |\var{x}}|{\var{x}|
|000016f0| 20 75 6e 63 68 61 6e 67 | 65 64 7d 7b 7d 0d 20 20 | unchang|ed}{}. |
|00001700| 5c 6c 69 6e 65 69 69 69 | 7b 5c 76 61 72 7b 78 7d |\lineiii|{\var{x}|
|00001710| 20 2b 20 5c 76 61 72 7b | 79 7d 7d 7b 73 75 6d 20 | + \var{|y}}{sum |
|00001720| 6f 66 20 5c 76 61 72 7b | 78 7d 20 61 6e 64 20 5c |of \var{|x} and \|
|00001730| 76 61 72 7b 79 7d 7d 7b | 7d 0d 20 20 5c 6c 69 6e |var{y}}{|}. \lin|
|00001740| 65 69 69 69 7b 5c 76 61 | 72 7b 78 7d 20 2d 20 5c |eiii{\va|r{x} - \|
|00001750| 76 61 72 7b 79 7d 7d 7b | 64 69 66 66 65 72 65 6e |var{y}}{|differen|
|00001760| 63 65 20 6f 66 20 5c 76 | 61 72 7b 78 7d 20 61 6e |ce of \v|ar{x} an|
|00001770| 64 20 5c 76 61 72 7b 79 | 7d 7d 7b 7d 0d 20 20 5c |d \var{y|}}{}. \|
|00001780| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 78 7d 20 |lineiii{|\var{x} |
|00001790| 2a 20 5c 76 61 72 7b 79 | 7d 7d 7b 70 72 6f 64 75 |* \var{y|}}{produ|
|000017a0| 63 74 20 6f 66 20 5c 76 | 61 72 7b 78 7d 20 61 6e |ct of \v|ar{x} an|
|000017b0| 64 20 5c 76 61 72 7b 79 | 7d 7d 7b 7d 0d 20 20 5c |d \var{y|}}{}. \|
|000017c0| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 78 7d 20 |lineiii{|\var{x} |
|000017d0| 2f 20 5c 76 61 72 7b 79 | 7d 7d 7b 71 75 6f 74 69 |/ \var{y|}}{quoti|
|000017e0| 65 6e 74 20 6f 66 20 5c | 76 61 72 7b 78 7d 20 61 |ent of \|var{x} a|
|000017f0| 6e 64 20 5c 76 61 72 7b | 79 7d 7d 7b 28 32 29 7d |nd \var{|y}}{(2)}|
|00001800| 0d 20 20 5c 6c 69 6e 65 | 69 69 69 7b 5c 76 61 72 |. \line|iii{\var|
|00001810| 7b 78 7d 20 5c 25 7b 7d | 20 5c 76 61 72 7b 79 7d |{x} \%{}| \var{y}|
|00001820| 7d 7b 72 65 6d 61 69 6e | 64 65 72 20 6f 66 20 5c |}{remain|der of \|
|00001830| 63 6f 64 65 7b 5c 76 61 | 72 7b 78 7d 20 2f 20 5c |code{\va|r{x} / \|
|00001840| 76 61 72 7b 79 7d 7d 7d | 7b 7d 0d 20 20 5c 6c 69 |var{y}}}|{}. \li|
|00001850| 6e 65 69 69 69 7b 64 69 | 76 6d 6f 64 28 5c 76 61 |neiii{di|vmod(\va|
|00001860| 72 7b 78 7d 2c 20 5c 76 | 61 72 7b 79 7d 29 7d 7b |r{x}, \v|ar{y})}{|
|00001870| 74 68 65 20 70 61 69 72 | 20 5c 63 6f 64 65 7b 28 |the pair| \code{(|
|00001880| 5c 76 61 72 7b 78 7d 20 | 2f 20 5c 76 61 72 7b 79 |\var{x} |/ \var{y|
|00001890| 7d 2c 20 5c 76 61 72 7b | 78 7d 20 5c 25 7b 7d 20 |}, \var{|x} \%{} |
|000018a0| 5c 76 61 72 7b 79 7d 29 | 7d 7d 7b 28 33 29 7d 0d |\var{y})|}}{(3)}.|
|000018b0| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 70 6f 77 28 5c | \linei|ii{pow(\|
|000018c0| 76 61 72 7b 78 7d 2c 20 | 5c 76 61 72 7b 79 7d 29 |var{x}, |\var{y})|
|000018d0| 7d 7b 5c 76 61 72 7b 78 | 7d 20 74 6f 20 74 68 65 |}{\var{x|} to the|
|000018e0| 20 70 6f 77 65 72 20 5c | 76 61 72 7b 79 7d 7d 7b | power \|var{y}}{|
|000018f0| 7d 0d 5c 65 6e 64 7b 74 | 61 62 6c 65 69 69 69 7d |}.\end{t|ableiii}|
|00001900| 0d 5c 69 6e 64 65 78 69 | 69 69 7b 6f 70 65 72 61 |.\indexi|ii{opera|
|00001910| 74 69 6f 6e 73 20 6f 6e | 7d 7b 6e 75 6d 65 72 69 |tions on|}{numeri|
|00001920| 63 7d 7b 74 79 70 65 73 | 7d 0d 0d 5c 6e 6f 69 6e |c}{types|}..\noin|
|00001930| 64 65 6e 74 0d 4e 6f 74 | 65 73 3a 0d 5c 62 65 67 |dent.Not|es:.\beg|
|00001940| 69 6e 7b 64 65 73 63 72 | 69 70 74 69 6f 6e 7d 0d |in{descr|iption}.|
|00001950| 5c 69 74 65 6d 5b 28 31 | 29 5d 0d 43 6f 6e 76 65 |\item[(1|)].Conve|
|00001960| 72 73 69 6f 6e 20 66 72 | 6f 6d 20 66 6c 6f 61 74 |rsion fr|om float|
|00001970| 69 6e 67 20 70 6f 69 6e | 74 20 74 6f 20 28 6c 6f |ing poin|t to (lo|
|00001980| 6e 67 20 6f 72 20 70 6c | 61 69 6e 29 20 69 6e 74 |ng or pl|ain) int|
|00001990| 65 67 65 72 20 6d 61 79 | 20 72 6f 75 6e 64 20 6f |eger may| round o|
|000019a0| 72 0d 25 20 58 58 58 4a | 48 20 78 72 65 66 20 68 |r.% XXXJ|H xref h|
|000019b0| 65 72 65 0d 74 72 75 6e | 63 61 74 65 20 61 73 20 |ere.trun|cate as |
|000019c0| 69 6e 20 5c 43 7b 7d 3b | 20 73 65 65 20 66 75 6e |in \C{};| see fun|
|000019d0| 63 74 69 6f 6e 73 20 5c | 63 6f 64 65 7b 66 6c 6f |ctions \|code{flo|
|000019e0| 6f 72 7d 20 61 6e 64 20 | 5c 63 6f 64 65 7b 63 65 |or} and |\code{ce|
|000019f0| 69 6c 7d 20 69 6e 20 6d | 6f 64 75 6c 65 0d 5c 63 |il} in m|odule.\c|
|00001a00| 6f 64 65 7b 6d 61 74 68 | 7d 20 66 6f 72 20 77 65 |ode{math|} for we|
|00001a10| 6c 6c 2d 64 65 66 69 6e | 65 64 20 63 6f 6e 76 65 |ll-defin|ed conve|
|00001a20| 72 73 69 6f 6e 73 2e 0d | 5c 69 6e 64 65 78 69 69 |rsions..|\indexii|
|00001a30| 7b 6e 75 6d 65 72 69 63 | 7d 7b 63 6f 6e 76 65 72 |{numeric|}{conver|
|00001a40| 73 69 6f 6e 73 7d 0d 5c | 74 74 69 6e 64 65 78 7b |sions}.\|ttindex{|
|00001a50| 6d 61 74 68 7d 0d 5c 69 | 6e 64 65 78 69 69 7b 5c |math}.\i|ndexii{\|
|00001a60| 43 7b 7d 7d 7b 6c 61 6e | 67 75 61 67 65 7d 0d 0d |C{}}{lan|guage}..|
|00001a70| 5c 69 74 65 6d 5b 28 32 | 29 5d 0d 46 6f 72 20 28 |\item[(2|)].For (|
|00001a80| 70 6c 61 69 6e 20 6f 72 | 20 6c 6f 6e 67 29 20 69 |plain or| long) i|
|00001a90| 6e 74 65 67 65 72 20 64 | 69 76 69 73 69 6f 6e 2c |nteger d|ivision,|
|00001aa0| 20 74 68 65 20 72 65 73 | 75 6c 74 20 69 73 20 61 | the res|ult is a|
|00001ab0| 6e 20 69 6e 74 65 67 65 | 72 3b 20 69 74 0d 61 6c |n intege|r; it.al|
|00001ac0| 77 61 79 73 20 74 72 75 | 6e 63 61 74 65 73 20 74 |ways tru|ncates t|
|00001ad0| 6f 77 61 72 64 73 20 7a | 65 72 6f 2e 0d 25 20 58 |owards z|ero..% X|
|00001ae0| 58 58 4a 48 20 69 6e 74 | 65 67 65 72 20 64 69 76 |XXJH int|eger div|
|00001af0| 69 73 69 6f 6e 20 69 73 | 20 62 65 74 74 65 72 20 |ision is| better |
|00001b00| 64 65 66 69 6e 65 64 20 | 6e 6f 77 61 64 61 79 73 |defined |nowadays|
|00001b10| 0d 5c 69 6e 64 65 78 69 | 69 7b 69 6e 74 65 67 65 |.\indexi|i{intege|
|00001b20| 72 7d 7b 64 69 76 69 73 | 69 6f 6e 7d 0d 5c 69 6e |r}{divis|ion}.\in|
|00001b30| 64 65 78 69 69 69 7b 6c | 6f 6e 67 7d 7b 69 6e 74 |dexiii{l|ong}{int|
|00001b40| 65 67 65 72 7d 7b 64 69 | 76 69 73 69 6f 6e 7d 0d |eger}{di|vision}.|
|00001b50| 0d 5c 69 74 65 6d 5b 28 | 33 29 5d 0d 53 65 65 20 |.\item[(|3)].See |
|00001b60| 74 68 65 20 73 65 63 74 | 69 6f 6e 20 6f 6e 20 62 |the sect|ion on b|
|00001b70| 75 69 6c 74 2d 69 6e 20 | 66 75 6e 63 74 69 6f 6e |uilt-in |function|
|00001b80| 73 20 66 6f 72 20 61 6e | 20 65 78 61 63 74 20 64 |s for an| exact d|
|00001b90| 65 66 69 6e 69 74 69 6f | 6e 2e 0d 0d 5c 65 6e 64 |efinitio|n...\end|
|00001ba0| 7b 64 65 73 63 72 69 70 | 74 69 6f 6e 7d 0d 25 20 |{descrip|tion}.% |
|00001bb0| 58 58 58 4a 48 20 65 78 | 63 65 70 74 69 6f 6e 73 |XXXJH ex|ceptions|
|00001bc0| 3a 20 6f 76 65 72 66 6c | 6f 77 20 28 77 68 65 6e |: overfl|ow (when|
|00001bd0| 3f 20 77 68 61 74 20 6f | 70 65 72 61 74 69 6f 6e |? what o|peration|
|00001be0| 73 3f 29 20 7a 65 72 6f | 64 69 76 69 73 69 6f 6e |s?) zero|division|
|00001bf0| 0d 0d 5c 73 75 62 73 75 | 62 73 65 63 74 69 6f 6e |..\subsu|bsection|
|00001c00| 7b 42 69 74 2d 73 74 72 | 69 6e 67 20 4f 70 65 72 |{Bit-str|ing Oper|
|00001c10| 61 74 69 6f 6e 73 20 6f | 6e 20 49 6e 74 65 67 65 |ations o|n Intege|
|00001c20| 72 20 54 79 70 65 73 2e | 7d 0d 0d 50 6c 61 69 6e |r Types.|}..Plain|
|00001c30| 20 61 6e 64 20 6c 6f 6e | 67 20 69 6e 74 65 67 65 | and lon|g intege|
|00001c40| 72 20 74 79 70 65 73 20 | 73 75 70 70 6f 72 74 20 |r types |support |
|00001c50| 61 64 64 69 74 69 6f 6e | 61 6c 20 6f 70 65 72 61 |addition|al opera|
|00001c60| 74 69 6f 6e 73 20 74 68 | 61 74 20 6d 61 6b 65 0d |tions th|at make.|
|00001c70| 73 65 6e 73 65 20 6f 6e | 6c 79 20 66 6f 72 20 62 |sense on|ly for b|
|00001c80| 69 74 2d 73 74 72 69 6e | 67 73 2e 20 20 4e 65 67 |it-strin|gs. Neg|
|00001c90| 61 74 69 76 65 20 6e 75 | 6d 62 65 72 73 20 61 72 |ative nu|mbers ar|
|00001ca0| 65 20 74 72 65 61 74 65 | 64 20 61 73 20 74 68 65 |e treate|d as the|
|00001cb0| 69 72 20 32 27 73 0d 63 | 6f 6d 70 6c 65 6d 65 6e |ir 2's.c|omplemen|
|00001cc0| 74 20 76 61 6c 75 65 3a | 0d 0d 5c 62 65 67 69 6e |t value:|..\begin|
|00001cd0| 7b 74 61 62 6c 65 69 69 | 69 7d 7b 7c 63 7c 6c 7c |{tableii|i}{|c|l||
|00001ce0| 63 7c 7d 7b 63 6f 64 65 | 7d 7b 4f 70 65 72 61 74 |c|}{code|}{Operat|
|00001cf0| 69 6f 6e 7d 7b 52 65 73 | 75 6c 74 7d 7b 4e 6f 74 |ion}{Res|ult}{Not|
|00001d00| 65 73 7d 0d 20 20 5c 6c | 69 6e 65 69 69 69 7b 5c |es}. \l|ineiii{\|
|00001d10| 7e 5c 76 61 72 7b 78 7d | 7d 7b 74 68 65 20 62 69 |~\var{x}|}{the bi|
|00001d20| 74 73 20 6f 66 20 5c 76 | 61 72 7b 78 7d 20 69 6e |ts of \v|ar{x} in|
|00001d30| 76 65 72 74 65 64 7d 7b | 7d 0d 20 20 5c 6c 69 6e |verted}{|}. \lin|
|00001d40| 65 69 69 69 7b 5c 76 61 | 72 7b 78 7d 20 5c 5e 7b |eiii{\va|r{x} \^{|
|00001d50| 7d 20 5c 76 61 72 7b 79 | 7d 7d 7b 62 69 74 77 69 |} \var{y|}}{bitwi|
|00001d60| 73 65 20 5c 64 66 6e 7b | 65 78 63 6c 75 73 69 76 |se \dfn{|exclusiv|
|00001d70| 65 20 6f 72 7d 20 6f 66 | 20 5c 76 61 72 7b 78 7d |e or} of| \var{x}|
|00001d80| 20 61 6e 64 20 5c 76 61 | 72 7b 79 7d 7d 7b 7d 0d | and \va|r{y}}{}.|
|00001d90| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 5c 76 61 72 7b | \linei|ii{\var{|
|00001da0| 78 7d 20 5c 26 7b 7d 20 | 5c 76 61 72 7b 79 7d 7d |x} \&{} |\var{y}}|
|00001db0| 7b 62 69 74 77 69 73 65 | 20 5c 64 66 6e 7b 61 6e |{bitwise| \dfn{an|
|00001dc0| 64 7d 20 6f 66 20 5c 76 | 61 72 7b 78 7d 20 61 6e |d} of \v|ar{x} an|
|00001dd0| 64 20 5c 76 61 72 7b 79 | 7d 7d 7b 7d 0d 20 20 5c |d \var{y|}}{}. \|
|00001de0| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 78 7d 20 |lineiii{|\var{x} |
|00001df0| 7c 20 5c 76 61 72 7b 79 | 7d 7d 7b 62 69 74 77 69 || \var{y|}}{bitwi|
|00001e00| 73 65 20 5c 64 66 6e 7b | 6f 72 7d 20 6f 66 20 5c |se \dfn{|or} of \|
|00001e10| 76 61 72 7b 78 7d 20 61 | 6e 64 20 5c 76 61 72 7b |var{x} a|nd \var{|
|00001e20| 79 7d 7d 7b 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |y}}{}. |\lineiii|
|00001e30| 7b 5c 76 61 72 7b 78 7d | 20 3c 3c 20 5c 76 61 72 |{\var{x}| << \var|
|00001e40| 7b 6e 7d 7d 7b 5c 76 61 | 72 7b 78 7d 20 73 68 69 |{n}}{\va|r{x} shi|
|00001e50| 66 74 65 64 20 6c 65 66 | 74 20 62 79 20 5c 76 61 |fted lef|t by \va|
|00001e60| 72 7b 6e 7d 20 62 69 74 | 73 7d 7b 7d 0d 20 20 5c |r{n} bit|s}{}. \|
|00001e70| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 78 7d 20 |lineiii{|\var{x} |
|00001e80| 3e 3e 20 5c 76 61 72 7b | 6e 7d 7d 7b 5c 76 61 72 |>> \var{|n}}{\var|
|00001e90| 7b 78 7d 20 73 68 69 66 | 74 65 64 20 72 69 67 68 |{x} shif|ted righ|
|00001ea0| 74 20 62 79 20 5c 76 61 | 72 7b 6e 7d 20 62 69 74 |t by \va|r{n} bit|
|00001eb0| 73 7d 7b 7d 0d 5c 65 6e | 64 7b 74 61 62 6c 65 69 |s}{}.\en|d{tablei|
|00001ec0| 69 69 7d 0d 25 20 58 58 | 58 4a 48 20 77 68 61 74 |ii}.% XX|XJH what|
|00001ed0| 27 73 20 60 6c 65 66 74 | 27 3f 20 60 72 69 67 68 |'s `left|'? `righ|
|00001ee0| 74 27 3f 20 6d 61 79 62 | 65 20 62 65 74 74 65 72 |t'? mayb|e better|
|00001ef0| 20 75 73 65 20 6c 73 62 | 20 6f 72 20 6d 73 62 20 | use lsb| or msb |
|00001f00| 6f 72 20 73 6f 6d 65 74 | 68 69 6e 67 0d 5c 69 6e |or somet|hing.\in|
|00001f10| 64 65 78 69 69 69 7b 6f | 70 65 72 61 74 69 6f 6e |dexiii{o|peration|
|00001f20| 73 20 6f 6e 7d 7b 69 6e | 74 65 67 65 72 7d 7b 74 |s on}{in|teger}{t|
|00001f30| 79 70 65 73 7d 0d 5c 69 | 6e 64 65 78 69 69 7b 62 |ypes}.\i|ndexii{b|
|00001f40| 69 74 2d 73 74 72 69 6e | 67 7d 7b 6f 70 65 72 61 |it-strin|g}{opera|
|00001f50| 74 69 6f 6e 73 7d 0d 5c | 69 6e 64 65 78 69 69 7b |tions}.\|indexii{|
|00001f60| 73 68 69 66 74 69 6e 67 | 7d 7b 6f 70 65 72 61 74 |shifting|}{operat|
|00001f70| 69 6f 6e 73 7d 0d 5c 69 | 6e 64 65 78 69 69 7b 6d |ions}.\i|ndexii{m|
|00001f80| 61 73 6b 69 6e 67 7d 7b | 6f 70 65 72 61 74 69 6f |asking}{|operatio|
|00001f90| 6e 73 7d 0d 0d 5c 73 75 | 62 73 65 63 74 69 6f 6e |ns}..\su|bsection|
|00001fa0| 7b 53 65 71 75 65 6e 63 | 65 20 54 79 70 65 73 7d |{Sequenc|e Types}|
|00001fb0| 0d 0d 54 68 65 72 65 20 | 61 72 65 20 74 68 72 65 |..There |are thre|
|00001fc0| 65 20 73 65 71 75 65 6e | 63 65 20 74 79 70 65 73 |e sequen|ce types|
|00001fd0| 3a 20 73 74 72 69 6e 67 | 73 2c 20 6c 69 73 74 73 |: string|s, lists|
|00001fe0| 20 61 6e 64 20 74 75 70 | 6c 65 73 2e 0d 53 74 72 | and tup|les..Str|
|00001ff0| 69 6e 67 73 20 6c 69 74 | 65 72 61 6c 73 20 61 72 |ings lit|erals ar|
|00002000| 65 20 77 72 69 74 74 65 | 6e 20 69 6e 20 73 69 6e |e writte|n in sin|
|00002010| 67 6c 65 20 71 75 6f 74 | 65 73 3a 20 5c 63 6f 64 |gle quot|es: \cod|
|00002020| 65 7b 27 78 79 7a 7a 79 | 27 7d 2e 0d 4c 69 73 74 |e{'xyzzy|'}..List|
|00002030| 73 20 61 72 65 20 63 6f | 6e 73 74 72 75 63 74 65 |s are co|nstructe|
|00002040| 64 20 77 69 74 68 20 73 | 71 75 61 72 65 20 62 72 |d with s|quare br|
|00002050| 61 63 6b 65 74 73 2c 0d | 73 65 70 61 72 61 74 69 |ackets,.|separati|
|00002060| 6e 67 20 69 74 65 6d 73 | 20 77 69 74 68 20 63 6f |ng items| with co|
|00002070| 6d 6d 61 73 3a 0d 5c 63 | 6f 64 65 7b 5b 61 2c 20 |mmas:.\c|ode{[a, |
|00002080| 62 2c 20 63 5d 7d 2e 0d | 54 75 70 6c 65 73 20 61 |b, c]}..|Tuples a|
|00002090| 72 65 20 63 6f 6e 73 74 | 72 75 63 74 65 64 20 62 |re const|ructed b|
|000020a0| 79 20 74 68 65 20 63 6f | 6d 6d 61 20 6f 70 65 72 |y the co|mma oper|
|000020b0| 61 74 6f 72 0d 28 6e 6f | 74 20 77 69 74 68 69 6e |ator.(no|t within|
|000020c0| 20 73 71 75 61 72 65 20 | 62 72 61 63 6b 65 74 73 | square |brackets|
|000020d0| 29 2c 20 77 69 74 68 20 | 6f 72 20 77 69 74 68 6f |), with |or witho|
|000020e0| 75 74 20 65 6e 63 6c 6f | 73 69 6e 67 20 70 61 72 |ut enclo|sing par|
|000020f0| 65 6e 74 68 65 73 65 73 | 2c 0d 62 75 74 20 61 6e |entheses|,.but an|
|00002100| 20 65 6d 70 74 79 20 74 | 75 70 6c 65 20 6d 75 73 | empty t|uple mus|
|00002110| 74 20 68 61 76 65 20 74 | 68 65 20 65 6e 63 6c 6f |t have t|he enclo|
|00002120| 73 69 6e 67 20 70 61 72 | 65 6e 74 68 65 73 65 73 |sing par|entheses|
|00002130| 2c 20 65 2e 67 2e 2c 0d | 5c 63 6f 64 65 7b 61 2c |, e.g.,.|\code{a,|
|00002140| 20 62 2c 20 63 7d 20 6f | 72 20 5c 63 6f 64 65 7b | b, c} o|r \code{|
|00002150| 28 29 7d 2e 20 20 41 20 | 73 69 6e 67 6c 65 20 69 |()}. A |single i|
|00002160| 74 65 6d 20 74 75 70 6c | 65 20 6d 75 73 74 20 68 |tem tupl|e must h|
|00002170| 61 76 65 20 61 20 74 72 | 61 69 6c 69 6e 67 20 63 |ave a tr|ailing c|
|00002180| 6f 6d 6d 61 2c 0d 65 2e | 67 2e 2c 20 5c 63 6f 64 |omma,.e.|g., \cod|
|00002190| 65 7b 28 64 2c 29 7d 2e | 0d 5c 69 6e 64 65 78 69 |e{(d,)}.|.\indexi|
|000021a0| 69 7b 73 65 71 75 65 6e | 63 65 7d 7b 74 79 70 65 |i{sequen|ce}{type|
|000021b0| 73 7d 0d 5c 69 6e 64 65 | 78 69 69 7b 73 74 72 69 |s}.\inde|xii{stri|
|000021c0| 6e 67 7d 7b 74 79 70 65 | 7d 0d 5c 69 6e 64 65 78 |ng}{type|}.\index|
|000021d0| 69 69 7b 74 75 70 6c 65 | 7d 7b 74 79 70 65 7d 0d |ii{tuple|}{type}.|
|000021e0| 5c 69 6e 64 65 78 69 69 | 7b 6c 69 73 74 7d 7b 74 |\indexii|{list}{t|
|000021f0| 79 70 65 7d 0d 0d 53 65 | 71 75 65 6e 63 65 20 74 |ype}..Se|quence t|
|00002200| 79 70 65 73 20 73 75 70 | 70 6f 72 74 20 74 68 65 |ypes sup|port the|
|00002210| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 6f 70 65 72 61 | followi|ng opera|
|00002220| 74 69 6f 6e 73 20 28 5c | 76 61 72 7b 73 7d 20 61 |tions (\|var{s} a|
|00002230| 6e 64 20 5c 76 61 72 7b | 74 7d 20 61 72 65 0d 73 |nd \var{|t} are.s|
|00002240| 65 71 75 65 6e 63 65 73 | 20 6f 66 20 74 68 65 20 |equences| of the |
|00002250| 73 61 6d 65 20 74 79 70 | 65 3b 20 5c 76 61 72 7b |same typ|e; \var{|
|00002260| 6e 7d 2c 20 5c 76 61 72 | 7b 69 7d 20 61 6e 64 20 |n}, \var|{i} and |
|00002270| 5c 76 61 72 7b 6a 7d 20 | 61 72 65 20 69 6e 74 65 |\var{j} |are inte|
|00002280| 67 65 72 73 29 3a 0d 0d | 5c 62 65 67 69 6e 7b 74 |gers):..|\begin{t|
|00002290| 61 62 6c 65 69 69 69 7d | 7b 7c 63 7c 6c 7c 63 7c |ableiii}|{|c|l|c||
|000022a0| 7d 7b 63 6f 64 65 7d 7b | 4f 70 65 72 61 74 69 6f |}{code}{|Operatio|
|000022b0| 6e 7d 7b 52 65 73 75 6c | 74 7d 7b 4e 6f 74 65 73 |n}{Resul|t}{Notes|
|000022c0| 7d 0d 20 20 5c 6c 69 6e | 65 69 69 69 7b 6c 65 6e |}. \lin|eiii{len|
|000022d0| 28 5c 76 61 72 7b 73 7d | 29 7d 7b 6c 65 6e 67 74 |(\var{s}|)}{lengt|
|000022e0| 68 20 6f 66 20 5c 76 61 | 72 7b 73 7d 7d 7b 7d 0d |h of \va|r{s}}{}.|
|000022f0| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 6d 69 6e 28 5c | \linei|ii{min(\|
|00002300| 76 61 72 7b 73 7d 29 7d | 7b 73 6d 61 6c 6c 65 73 |var{s})}|{smalles|
|00002310| 74 20 69 74 65 6d 20 6f | 66 20 5c 76 61 72 7b 73 |t item o|f \var{s|
|00002320| 7d 7d 7b 7d 0d 20 20 5c | 6c 69 6e 65 69 69 69 7b |}}{}. \|lineiii{|
|00002330| 6d 61 78 28 5c 76 61 72 | 7b 73 7d 29 7d 7b 6c 61 |max(\var|{s})}{la|
|00002340| 72 67 65 73 74 20 69 74 | 65 6d 20 6f 66 20 5c 76 |rgest it|em of \v|
|00002350| 61 72 7b 73 7d 7d 7b 7d | 0d 20 20 5c 6c 69 6e 65 |ar{s}}{}|. \line|
|00002360| 69 69 69 7b 5c 76 61 72 | 7b 78 7d 20 69 6e 20 5c |iii{\var|{x} in \|
|00002370| 76 61 72 7b 73 7d 7d 7b | 5c 63 6f 64 65 7b 31 7d |var{s}}{|\code{1}|
|00002380| 20 69 66 20 61 6e 20 69 | 74 65 6d 20 6f 66 20 5c | if an i|tem of \|
|00002390| 76 61 72 7b 73 7d 20 69 | 73 20 65 71 75 61 6c 20 |var{s} i|s equal |
|000023a0| 74 6f 20 5c 76 61 72 7b | 78 7d 2c 20 65 6c 73 65 |to \var{|x}, else|
|000023b0| 20 5c 63 6f 64 65 7b 30 | 7d 7d 7b 7d 0d 20 20 5c | \code{0|}}{}. \|
|000023c0| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 78 7d 20 |lineiii{|\var{x} |
|000023d0| 6e 6f 74 20 69 6e 20 5c | 76 61 72 7b 73 7d 7d 7b |not in \|var{s}}{|
|000023e0| 5c 63 6f 64 65 7b 30 7d | 20 69 66 20 61 6e 20 69 |\code{0}| if an i|
|000023f0| 74 65 6d 20 6f 66 20 5c | 76 61 72 7b 73 7d 20 69 |tem of \|var{s} i|
|00002400| 73 20 65 71 75 61 6c 20 | 74 6f 20 5c 76 61 72 7b |s equal |to \var{|
|00002410| 78 7d 2c 20 65 6c 73 65 | 20 5c 63 6f 64 65 7b 31 |x}, else| \code{1|
|00002420| 7d 7d 7b 7d 0d 20 20 5c | 6c 69 6e 65 69 69 69 7b |}}{}. \|lineiii{|
|00002430| 5c 76 61 72 7b 73 7d 20 | 2b 20 5c 76 61 72 7b 74 |\var{s} |+ \var{t|
|00002440| 7d 7d 7b 74 68 65 20 63 | 6f 6e 63 61 74 65 6e 61 |}}{the c|oncatena|
|00002450| 74 69 6f 6e 20 6f 66 20 | 5c 76 61 72 7b 73 7d 20 |tion of |\var{s} |
|00002460| 61 6e 64 20 5c 76 61 72 | 7b 74 7d 7d 7b 7d 0d 20 |and \var|{t}}{}. |
|00002470| 20 5c 6c 69 6e 65 69 69 | 69 7b 5c 76 61 72 7b 73 | \lineii|i{\var{s|
|00002480| 7d 20 2a 20 5c 76 61 72 | 7b 6e 7d 7b 5c 72 6d 20 |} * \var|{n}{\rm |
|00002490| 2c 7d 20 5c 76 61 72 7b | 6e 7d 20 2a 20 5c 76 61 |,} \var{|n} * \va|
|000024a0| 72 7b 73 7d 7d 7b 5c 76 | 61 72 7b 6e 7d 20 63 6f |r{s}}{\v|ar{n} co|
|000024b0| 70 69 65 73 20 6f 66 20 | 5c 76 61 72 7b 73 7d 20 |pies of |\var{s} |
|000024c0| 63 6f 6e 63 61 74 65 6e | 61 74 65 64 7d 7b 7d 0d |concaten|ated}{}.|
|000024d0| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 5c 76 61 72 7b | \linei|ii{\var{|
|000024e0| 73 7d 5b 5c 76 61 72 7b | 69 7d 5d 7d 7b 5c 76 61 |s}[\var{|i}]}{\va|
|000024f0| 72 7b 69 7d 27 74 68 20 | 69 74 65 6d 20 6f 66 20 |r{i}'th |item of |
|00002500| 5c 76 61 72 7b 73 7d 2c | 20 6f 72 69 67 69 6e 20 |\var{s},| origin |
|00002510| 30 7d 7b 28 31 29 7d 0d | 20 20 5c 6c 69 6e 65 69 |0}{(1)}.| \linei|
|00002520| 69 69 7b 5c 76 61 72 7b | 73 7d 5b 5c 76 61 72 7b |ii{\var{|s}[\var{|
|00002530| 69 7d 3a 5c 76 61 72 7b | 6a 7d 5d 7d 7b 73 6c 69 |i}:\var{|j}]}{sli|
|00002540| 63 65 20 6f 66 20 5c 76 | 61 72 7b 73 7d 20 66 72 |ce of \v|ar{s} fr|
|00002550| 6f 6d 20 5c 76 61 72 7b | 69 7d 20 74 6f 20 5c 76 |om \var{|i} to \v|
|00002560| 61 72 7b 6a 7d 7d 7b 28 | 31 29 2c 20 28 32 29 7d |ar{j}}{(|1), (2)}|
|00002570| 0d 5c 65 6e 64 7b 74 61 | 62 6c 65 69 69 69 7d 0d |.\end{ta|bleiii}.|
|00002580| 5c 69 6e 64 65 78 69 69 | 69 7b 6f 70 65 72 61 74 |\indexii|i{operat|
|00002590| 69 6f 6e 73 20 6f 6e 7d | 7b 73 65 71 75 65 6e 63 |ions on}|{sequenc|
|000025a0| 65 7d 7b 74 79 70 65 73 | 7d 0d 5c 62 69 66 75 6e |e}{types|}.\bifun|
|000025b0| 63 69 6e 64 65 78 7b 6c | 65 6e 7d 0d 5c 62 69 66 |cindex{l|en}.\bif|
|000025c0| 75 6e 63 69 6e 64 65 78 | 7b 6d 69 6e 7d 0d 5c 62 |uncindex|{min}.\b|
|000025d0| 69 66 75 6e 63 69 6e 64 | 65 78 7b 6d 61 78 7d 0d |ifuncind|ex{max}.|
|000025e0| 5c 69 6e 64 65 78 69 69 | 7b 63 6f 6e 63 61 74 65 |\indexii|{concate|
|000025f0| 6e 61 74 69 6f 6e 7d 7b | 6f 70 65 72 61 74 69 6f |nation}{|operatio|
|00002600| 6e 7d 0d 5c 69 6e 64 65 | 78 69 69 7b 72 65 70 65 |n}.\inde|xii{repe|
|00002610| 74 69 74 69 6f 6e 7d 7b | 6f 70 65 72 61 74 69 6f |tition}{|operatio|
|00002620| 6e 7d 0d 5c 69 6e 64 65 | 78 69 69 7b 73 75 62 73 |n}.\inde|xii{subs|
|00002630| 63 72 69 70 74 7d 7b 6f | 70 65 72 61 74 69 6f 6e |cript}{o|peration|
|00002640| 7d 0d 5c 69 6e 64 65 78 | 69 69 7b 73 6c 69 63 65 |}.\index|ii{slice|
|00002650| 7d 7b 6f 70 65 72 61 74 | 69 6f 6e 7d 0d 5c 6f 70 |}{operat|ion}.\op|
|00002660| 69 6e 64 65 78 7b 69 6e | 7d 0d 5c 6f 70 69 6e 64 |index{in|}.\opind|
|00002670| 65 78 7b 6e 6f 74 20 69 | 6e 7d 0d 0d 5c 6e 6f 69 |ex{not i|n}..\noi|
|00002680| 6e 64 65 6e 74 0d 4e 6f | 74 65 73 3a 0d 0d 25 20 |ndent.No|tes:..% |
|00002690| 58 58 58 4a 48 20 61 6c | 6c 20 54 65 58 2d 6d 61 |XXXJH al|l TeX-ma|
|000026a0| 74 68 20 65 78 70 72 65 | 73 73 69 6f 6e 73 20 72 |th expre|ssions r|
|000026b0| 65 70 6c 61 63 65 64 20 | 62 79 20 70 79 74 68 6f |eplaced |by pytho|
|000026c0| 6e 2d 73 79 6e 74 61 78 | 20 65 78 70 72 65 73 73 |n-syntax| express|
|000026d0| 69 6f 6e 73 0d 5c 62 65 | 67 69 6e 7b 64 65 73 63 |ions.\be|gin{desc|
|000026e0| 72 69 70 74 69 6f 6e 7d | 0d 20 20 0d 5c 69 74 65 |ription}|. .\ite|
|000026f0| 6d 5b 28 31 29 5d 20 49 | 66 20 5c 76 61 72 7b 69 |m[(1)] I|f \var{i|
|00002700| 7d 20 6f 72 20 5c 76 61 | 72 7b 6a 7d 20 69 73 20 |} or \va|r{j} is |
|00002710| 6e 65 67 61 74 69 76 65 | 2c 20 74 68 65 20 69 6e |negative|, the in|
|00002720| 64 65 78 20 69 73 20 72 | 65 6c 61 74 69 76 65 20 |dex is r|elative |
|00002730| 74 6f 0d 20 20 74 68 65 | 20 65 6e 64 20 6f 66 20 |to. the| end of |
|00002740| 74 68 65 20 73 74 72 69 | 6e 67 2c 20 69 2e 65 2e |the stri|ng, i.e.|
|00002750| 2c 20 5c 63 6f 64 65 7b | 6c 65 6e 28 5c 76 61 72 |, \code{|len(\var|
|00002760| 7b 73 7d 29 20 2b 20 5c | 76 61 72 7b 69 7d 7d 20 |{s}) + \|var{i}} |
|00002770| 6f 72 0d 20 20 5c 63 6f | 64 65 7b 6c 65 6e 28 5c |or. \co|de{len(\|
|00002780| 76 61 72 7b 73 7d 29 20 | 2b 20 5c 76 61 72 7b 6a |var{s}) |+ \var{j|
|00002790| 7d 7d 20 69 73 20 73 75 | 62 73 74 69 74 75 74 65 |}} is su|bstitute|
|000027a0| 64 2e 20 20 42 75 74 20 | 6e 6f 74 65 20 74 68 61 |d. But |note tha|
|000027b0| 74 20 5c 63 6f 64 65 7b | 2d 30 7d 20 69 73 0d 20 |t \code{|-0} is. |
|000027c0| 20 73 74 69 6c 6c 20 5c | 63 6f 64 65 7b 30 7d 2e | still \|code{0}.|
|000027d0| 0d 20 20 0d 5c 69 74 65 | 6d 5b 28 32 29 5d 20 54 |. .\ite|m[(2)] T|
|000027e0| 68 65 20 73 6c 69 63 65 | 20 6f 66 20 5c 76 61 72 |he slice| of \var|
|000027f0| 7b 73 7d 20 66 72 6f 6d | 20 5c 76 61 72 7b 69 7d |{s} from| \var{i}|
|00002800| 20 74 6f 20 5c 76 61 72 | 7b 6a 7d 20 69 73 20 64 | to \var|{j} is d|
|00002810| 65 66 69 6e 65 64 20 61 | 73 0d 20 20 74 68 65 20 |efined a|s. the |
|00002820| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 69 74 65 6d |sequence| of item|
|00002830| 73 20 77 69 74 68 20 69 | 6e 64 65 78 20 5c 76 61 |s with i|ndex \va|
|00002840| 72 7b 6b 7d 20 73 75 63 | 68 20 74 68 61 74 20 5c |r{k} suc|h that \|
|00002850| 63 6f 64 65 7b 5c 76 61 | 72 7b 69 7d 20 3c 3d 0d |code{\va|r{i} <=.|
|00002860| 20 20 5c 76 61 72 7b 6b | 7d 20 3c 20 5c 76 61 72 | \var{k|} < \var|
|00002870| 7b 6a 7d 7d 2e 20 20 49 | 66 20 5c 76 61 72 7b 69 |{j}}. I|f \var{i|
|00002880| 7d 20 6f 72 20 5c 76 61 | 72 7b 6a 7d 20 69 73 20 |} or \va|r{j} is |
|00002890| 67 72 65 61 74 65 72 20 | 74 68 61 6e 0d 20 20 5c |greater |than. \|
|000028a0| 63 6f 64 65 7b 6c 65 6e | 28 5c 76 61 72 7b 73 7d |code{len|(\var{s}|
|000028b0| 29 7d 2c 20 75 73 65 20 | 5c 63 6f 64 65 7b 6c 65 |)}, use |\code{le|
|000028c0| 6e 28 5c 76 61 72 7b 73 | 7d 29 7d 2e 20 20 49 66 |n(\var{s|})}. If|
|000028d0| 20 5c 76 61 72 7b 69 7d | 20 69 73 20 6f 6d 69 74 | \var{i}| is omit|
|000028e0| 74 65 64 2c 0d 20 20 75 | 73 65 20 5c 63 6f 64 65 |ted,. u|se \code|
|000028f0| 7b 30 7d 2e 20 20 49 66 | 20 5c 76 61 72 7b 6a 7d |{0}. If| \var{j}|
|00002900| 20 69 73 20 6f 6d 69 74 | 74 65 64 2c 20 75 73 65 | is omit|ted, use|
|00002910| 20 5c 63 6f 64 65 7b 6c | 65 6e 28 5c 76 61 72 7b | \code{l|en(\var{|
|00002920| 73 7d 29 7d 2e 20 20 49 | 66 0d 20 20 5c 76 61 72 |s})}. I|f. \var|
|00002930| 7b 69 7d 20 69 73 20 67 | 72 65 61 74 65 72 20 74 |{i} is g|reater t|
|00002940| 68 61 6e 20 6f 72 20 65 | 71 75 61 6c 20 74 6f 20 |han or e|qual to |
|00002950| 5c 76 61 72 7b 6a 7d 2c | 20 74 68 65 20 73 6c 69 |\var{j},| the sli|
|00002960| 63 65 20 69 73 20 65 6d | 70 74 79 2e 0d 0d 5c 65 |ce is em|pty...\e|
|00002970| 6e 64 7b 64 65 73 63 72 | 69 70 74 69 6f 6e 7d 0d |nd{descr|iption}.|
|00002980| 0d 5c 73 75 62 73 75 62 | 73 65 63 74 69 6f 6e 7b |.\subsub|section{|
|00002990| 4d 6f 72 65 20 53 74 72 | 69 6e 67 20 4f 70 65 72 |More Str|ing Oper|
|000029a0| 61 74 69 6f 6e 73 2e 7d | 0d 0d 53 74 72 69 6e 67 |ations.}|..String|
|000029b0| 20 6f 62 6a 65 63 74 73 | 20 68 61 76 65 20 6f 6e | objects| have on|
|000029c0| 65 20 75 6e 69 71 75 65 | 20 62 75 69 6c 74 2d 69 |e unique| built-i|
|000029d0| 6e 20 6f 70 65 72 61 74 | 69 6f 6e 3a 20 74 68 65 |n operat|ion: the|
|000029e0| 20 5c 63 6f 64 65 7b 5c | 25 7d 0d 6f 70 65 72 61 | \code{\|%}.opera|
|000029f0| 74 6f 72 20 28 6d 6f 64 | 75 6c 6f 29 20 77 69 74 |tor (mod|ulo) wit|
|00002a00| 68 20 61 20 73 74 72 69 | 6e 67 20 6c 65 66 74 20 |h a stri|ng left |
|00002a10| 61 72 67 75 6d 65 6e 74 | 20 69 6e 74 65 72 70 72 |argument| interpr|
|00002a20| 65 74 73 20 74 68 69 73 | 20 73 74 72 69 6e 67 0d |ets this| string.|
|00002a30| 61 73 20 61 20 43 20 73 | 70 72 69 6e 74 66 20 66 |as a C s|printf f|
|00002a40| 6f 72 6d 61 74 20 73 74 | 72 69 6e 67 20 74 6f 20 |ormat st|ring to |
|00002a50| 62 65 20 61 70 70 6c 69 | 65 64 20 74 6f 20 74 68 |be appli|ed to th|
|00002a60| 65 20 72 69 67 68 74 20 | 61 72 67 75 6d 65 6e 74 |e right |argument|
|00002a70| 2c 20 61 6e 64 0d 72 65 | 74 75 72 6e 73 20 74 68 |, and.re|turns th|
|00002a80| 65 20 73 74 72 69 6e 67 | 20 72 65 73 75 6c 74 69 |e string| resulti|
|00002a90| 6e 67 20 66 72 6f 6d 20 | 74 68 69 73 20 66 6f 72 |ng from |this for|
|00002aa0| 6d 61 74 74 69 6e 67 20 | 6f 70 65 72 61 74 69 6f |matting |operatio|
|00002ab0| 6e 2e 0d 0d 54 68 65 20 | 72 69 67 68 74 20 61 72 |n...The |right ar|
|00002ac0| 67 75 6d 65 6e 74 20 73 | 68 6f 75 6c 64 20 62 65 |gument s|hould be|
|00002ad0| 20 61 20 74 75 70 6c 65 | 20 77 69 74 68 20 6f 6e | a tuple| with on|
|00002ae0| 65 20 69 74 65 6d 20 66 | 6f 72 20 65 61 63 68 20 |e item f|or each |
|00002af0| 61 72 67 75 6d 65 6e 74 | 0d 72 65 71 75 69 72 65 |argument|.require|
|00002b00| 64 20 62 79 20 74 68 65 | 20 66 6f 72 6d 61 74 20 |d by the| format |
|00002b10| 73 74 72 69 6e 67 3b 20 | 69 66 20 74 68 65 20 73 |string; |if the s|
|00002b20| 74 72 69 6e 67 20 72 65 | 71 75 69 72 65 73 20 61 |tring re|quires a|
|00002b30| 20 73 69 6e 67 6c 65 0d | 61 72 67 75 6d 65 6e 74 | single.|argument|
|00002b40| 2c 20 74 68 65 20 72 69 | 67 68 74 20 61 72 67 75 |, the ri|ght argu|
|00002b50| 6d 65 6e 74 20 6d 61 79 | 20 61 6c 73 6f 20 62 65 |ment may| also be|
|00002b60| 20 61 20 73 69 6e 67 6c | 65 20 6e 6f 6e 2d 74 75 | a singl|e non-tu|
|00002b70| 70 6c 65 20 6f 62 6a 65 | 63 74 2e 25 0d 5c 66 6f |ple obje|ct.%.\fo|
|00002b80| 6f 74 6e 6f 74 65 7b 41 | 20 74 75 70 6c 65 20 6f |otnote{A| tuple o|
|00002b90| 62 6a 65 63 74 20 69 6e | 20 74 68 69 73 20 63 61 |bject in| this ca|
|00002ba0| 73 65 20 73 68 6f 75 6c | 64 20 62 65 20 61 20 73 |se shoul|d be a s|
|00002bb0| 69 6e 67 6c 65 74 6f 6e | 2e 7d 0d 54 68 65 20 66 |ingleton|.}.The f|
|00002bc0| 6f 6c 6c 6f 77 69 6e 67 | 20 66 6f 72 6d 61 74 20 |ollowing| format |
|00002bd0| 63 68 61 72 61 63 74 65 | 72 73 20 61 72 65 20 75 |characte|rs are u|
|00002be0| 6e 64 65 72 73 74 6f 6f | 64 3a 0d 5c 25 2c 20 63 |nderstoo|d:.\%, c|
|00002bf0| 2c 20 73 2c 20 69 2c 20 | 64 2c 20 75 2c 20 6f 2c |, s, i, |d, u, o,|
|00002c00| 20 78 2c 20 58 2c 20 65 | 2c 20 45 2c 20 66 2c 20 | x, X, e|, E, f, |
|00002c10| 67 2c 20 47 2e 0d 57 69 | 64 74 68 20 61 6e 64 20 |g, G..Wi|dth and |
|00002c20| 70 72 65 63 69 73 69 6f | 6e 20 6d 61 79 20 62 65 |precisio|n may be|
|00002c30| 20 61 20 2a 20 74 6f 20 | 73 70 65 63 69 66 79 20 | a * to |specify |
|00002c40| 74 68 61 74 20 61 6e 20 | 69 6e 74 65 67 65 72 20 |that an |integer |
|00002c50| 61 72 67 75 6d 65 6e 74 | 0d 73 70 65 63 69 66 69 |argument|.specifi|
|00002c60| 65 73 20 74 68 65 20 61 | 63 74 75 61 6c 20 77 69 |es the a|ctual wi|
|00002c70| 64 74 68 20 6f 72 20 70 | 72 65 63 69 73 69 6f 6e |dth or p|recision|
|00002c80| 2e 20 20 54 68 65 20 66 | 6c 61 67 20 63 68 61 72 |. The f|lag char|
|00002c90| 61 63 74 65 72 73 20 2d | 2c 20 2b 2c 0d 62 6c 61 |acters -|, +,.bla|
|00002ca0| 6e 6b 2c 20 5c 23 20 61 | 6e 64 20 30 20 61 72 65 |nk, \# a|nd 0 are|
|00002cb0| 20 75 6e 64 65 72 73 74 | 6f 6f 64 2e 20 20 54 68 | underst|ood. Th|
|00002cc0| 65 20 73 69 7a 65 20 73 | 70 65 63 69 66 69 65 72 |e size s|pecifier|
|00002cd0| 73 20 68 2c 20 6c 20 6f | 72 20 4c 20 6d 61 79 20 |s h, l o|r L may |
|00002ce0| 62 65 0d 70 72 65 73 65 | 6e 74 20 62 75 74 20 61 |be.prese|nt but a|
|00002cf0| 72 65 20 69 67 6e 6f 72 | 65 64 2e 20 20 54 68 65 |re ignor|ed. The|
|00002d00| 20 5c 63 6f 64 65 7b 5c | 25 73 7d 20 63 6f 6e 76 | \code{\|%s} conv|
|00002d10| 65 72 73 69 6f 6e 20 74 | 61 6b 65 73 20 61 6e 79 |ersion t|akes any|
|00002d20| 20 50 79 74 68 6f 6e 0d | 6f 62 6a 65 63 74 20 61 | Python.|object a|
|00002d30| 6e 64 20 63 6f 6e 76 65 | 72 74 73 20 69 74 20 74 |nd conve|rts it t|
|00002d40| 6f 20 61 20 73 74 72 69 | 6e 67 20 75 73 69 6e 67 |o a stri|ng using|
|00002d50| 20 5c 63 6f 64 65 7b 73 | 74 72 28 29 7d 20 62 65 | \code{s|tr()} be|
|00002d60| 66 6f 72 65 0d 66 6f 72 | 6d 61 74 74 69 6e 67 20 |fore.for|matting |
|00002d70| 69 74 2e 20 20 54 68 65 | 20 41 4e 53 49 20 66 65 |it. The| ANSI fe|
|00002d80| 61 74 75 72 65 73 20 5c | 63 6f 64 65 7b 5c 25 70 |atures \|code{\%p|
|00002d90| 7d 20 61 6e 64 20 5c 63 | 6f 64 65 7b 5c 25 6e 7d |} and \c|ode{\%n}|
|00002da0| 0d 61 72 65 20 6e 6f 74 | 20 73 75 70 70 6f 72 74 |.are not| support|
|00002db0| 65 64 2e 20 20 53 69 6e | 63 65 20 50 79 74 68 6f |ed. Sin|ce Pytho|
|00002dc0| 6e 20 73 74 72 69 6e 67 | 73 20 68 61 76 65 20 61 |n string|s have a|
|00002dd0| 6e 20 65 78 70 6c 69 63 | 69 74 20 6c 65 6e 67 74 |n explic|it lengt|
|00002de0| 68 2c 0d 5c 63 6f 64 65 | 7b 5c 25 73 7d 20 63 6f |h,.\code|{\%s} co|
|00002df0| 6e 76 65 72 73 69 6f 6e | 73 20 64 6f 6e 27 74 20 |nversion|s don't |
|00002e00| 61 73 73 75 6d 65 20 74 | 68 61 74 20 5c 63 6f 64 |assume t|hat \cod|
|00002e10| 65 7b 27 5c 5c 30 27 7d | 20 69 73 20 74 68 65 20 |e{'\\0'}| is the |
|00002e20| 65 6e 64 20 6f 66 0d 74 | 68 65 20 73 74 72 69 6e |end of.t|he strin|
|00002e30| 67 2e 0d 0d 46 6f 72 20 | 73 61 66 65 74 79 20 72 |g...For |safety r|
|00002e40| 65 61 73 6f 6e 73 2c 20 | 66 6c 6f 61 74 69 6e 67 |easons, |floating|
|00002e50| 20 70 6f 69 6e 74 20 70 | 72 65 63 69 73 69 6f 6e | point p|recision|
|00002e60| 73 20 61 72 65 20 63 6c | 69 70 70 65 64 20 74 6f |s are cl|ipped to|
|00002e70| 20 35 30 3b 0d 5c 63 6f | 64 65 7b 5c 25 66 7d 20 | 50;.\co|de{\%f} |
|00002e80| 63 6f 6e 76 65 72 73 69 | 6f 6e 73 20 66 6f 72 20 |conversi|ons for |
|00002e90| 6e 75 6d 62 65 72 73 20 | 77 68 6f 73 65 20 61 62 |numbers |whose ab|
|00002ea0| 73 6f 6c 75 74 65 20 76 | 61 6c 75 65 20 69 73 20 |solute v|alue is |
|00002eb0| 6f 76 65 72 20 31 65 32 | 35 0d 61 72 65 20 72 65 |over 1e2|5.are re|
|00002ec0| 70 6c 61 63 65 64 20 62 | 79 20 5c 63 6f 64 65 7b |placed b|y \code{|
|00002ed0| 5c 25 67 7d 20 63 6f 6e | 76 65 72 73 69 6f 6e 73 |\%g} con|versions|
|00002ee0| 2e 25 0d 5c 66 6f 6f 74 | 6e 6f 74 65 7b 54 68 65 |.%.\foot|note{The|
|00002ef0| 73 65 20 6e 75 6d 62 65 | 72 73 20 61 72 65 20 66 |se numbe|rs are f|
|00002f00| 61 69 72 6c 79 20 61 72 | 62 69 74 72 61 72 79 2e |airly ar|bitrary.|
|00002f10| 20 20 54 68 65 79 20 61 | 72 65 20 69 6e 74 65 6e | They a|re inten|
|00002f20| 64 65 64 20 74 6f 0d 61 | 76 6f 69 64 20 70 72 69 |ded to.a|void pri|
|00002f30| 6e 74 69 6e 67 20 65 6e | 64 6c 65 73 73 20 73 74 |nting en|dless st|
|00002f40| 72 69 6e 67 73 20 6f 66 | 20 6d 65 61 6e 69 6e 67 |rings of| meaning|
|00002f50| 6c 65 73 73 20 64 69 67 | 69 74 73 20 77 69 74 68 |less dig|its with|
|00002f60| 6f 75 74 20 68 61 6d 70 | 65 72 69 6e 67 0d 63 6f |out hamp|ering.co|
|00002f70| 72 72 65 63 74 20 75 73 | 65 20 61 6e 64 20 77 69 |rrect us|e and wi|
|00002f80| 74 68 6f 75 74 20 68 61 | 76 69 6e 67 20 74 6f 20 |thout ha|ving to |
|00002f90| 6b 6e 6f 77 20 74 68 65 | 20 65 78 61 63 74 20 70 |know the| exact p|
|00002fa0| 72 65 63 69 73 69 6f 6e | 20 6f 66 20 66 6c 6f 61 |recision| of floa|
|00002fb0| 74 69 6e 67 0d 70 6f 69 | 6e 74 20 76 61 6c 75 65 |ting.poi|nt value|
|00002fc0| 73 20 6f 6e 20 61 20 70 | 61 72 74 69 63 75 6c 61 |s on a p|articula|
|00002fd0| 72 20 6d 61 63 68 69 6e | 65 2e 7d 0d 41 6c 6c 20 |r machin|e.}.All |
|00002fe0| 6f 74 68 65 72 20 65 72 | 72 6f 72 73 20 72 61 69 |other er|rors rai|
|00002ff0| 73 65 20 65 78 63 65 70 | 74 69 6f 6e 73 2e 0d 0d |se excep|tions...|
|00003000| 49 66 20 74 68 65 20 72 | 69 67 68 74 20 61 72 67 |If the r|ight arg|
|00003010| 75 6d 65 6e 74 20 69 73 | 20 61 20 64 69 63 74 69 |ument is| a dicti|
|00003020| 6f 6e 61 72 79 20 28 6f | 72 20 61 6e 79 20 6b 69 |onary (o|r any ki|
|00003030| 6e 64 20 6f 66 20 6d 61 | 70 70 69 6e 67 29 2c 20 |nd of ma|pping), |
|00003040| 74 68 65 6e 0d 74 68 65 | 20 66 6f 72 6d 61 74 73 |then.the| formats|
|00003050| 20 69 6e 20 74 68 65 20 | 73 74 72 69 6e 67 20 6d | in the |string m|
|00003060| 75 73 74 20 68 61 76 65 | 20 61 20 70 61 72 65 6e |ust have| a paren|
|00003070| 74 68 65 73 69 7a 65 64 | 20 6b 65 79 20 69 6e 74 |thesized| key int|
|00003080| 6f 20 74 68 61 74 0d 64 | 69 63 74 69 6f 6e 61 72 |o that.d|ictionar|
|00003090| 79 20 69 6e 73 65 72 74 | 65 64 20 69 6d 6d 65 64 |y insert|ed immed|
|000030a0| 69 61 74 65 6c 79 20 61 | 66 74 65 72 20 74 68 65 |iately a|fter the|
|000030b0| 20 5c 63 6f 64 65 7b 5c | 25 7d 20 63 68 61 72 61 | \code{\|%} chara|
|000030c0| 63 74 65 72 2c 20 61 6e | 64 0d 65 61 63 68 20 66 |cter, an|d.each f|
|000030d0| 6f 72 6d 61 74 20 66 6f | 72 6d 61 74 73 20 74 68 |ormat fo|rmats th|
|000030e0| 65 20 63 6f 72 72 65 73 | 70 6f 6e 64 69 6e 67 20 |e corres|ponding |
|000030f0| 65 6e 74 72 79 20 66 72 | 6f 6d 20 74 68 65 20 6d |entry fr|om the m|
|00003100| 61 70 70 69 6e 67 2e 20 | 20 45 2e 67 2e 0d 5c 62 |apping. | E.g..\b|
|00003110| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0d 20 |egin{ver|batim}. |
|00003120| 20 20 20 3e 3e 3e 20 63 | 6f 75 6e 74 20 3d 20 32 | >>> c|ount = 2|
|00003130| 0d 20 20 20 20 3e 3e 3e | 20 6c 61 6e 67 75 61 67 |. >>>| languag|
|00003140| 65 20 3d 20 27 50 79 74 | 68 6f 6e 27 0d 20 20 20 |e = 'Pyt|hon'. |
|00003150| 20 3e 3e 3e 20 70 72 69 | 6e 74 20 27 25 28 6c 61 | >>> pri|nt '%(la|
|00003160| 6e 67 75 61 67 65 29 73 | 20 68 61 73 20 25 28 63 |nguage)s| has %(c|
|00003170| 6f 75 6e 74 29 30 33 64 | 20 71 75 6f 74 65 20 74 |ount)03d| quote t|
|00003180| 79 70 65 73 2e 27 20 25 | 20 76 61 72 73 28 29 0d |ypes.' %| vars().|
|00003190| 20 20 20 20 50 79 74 68 | 6f 6e 20 68 61 73 20 30 | Pyth|on has 0|
|000031a0| 30 32 20 71 75 6f 74 65 | 20 74 79 70 65 73 2e 0d |02 quote| types..|
|000031b0| 20 20 20 20 3e 3e 3e 20 | 0d 5c 65 6e 64 7b 76 65 | >>> |.\end{ve|
|000031c0| 72 62 61 74 69 6d 7d 0d | 49 6e 20 74 68 69 73 20 |rbatim}.|In this |
|000031d0| 63 61 73 65 20 6e 6f 20 | 2a 20 73 70 65 63 69 66 |case no |* specif|
|000031e0| 69 65 72 73 20 6d 61 79 | 20 6f 63 63 75 72 20 69 |iers may| occur i|
|000031f0| 6e 20 61 20 66 6f 72 6d | 61 74 2e 0d 0d 41 64 64 |n a form|at...Add|
|00003200| 69 74 69 6f 6e 61 6c 20 | 73 74 72 69 6e 67 20 6f |itional |string o|
|00003210| 70 65 72 61 74 69 6f 6e | 73 20 61 72 65 20 64 65 |peration|s are de|
|00003220| 66 69 6e 65 64 20 69 6e | 20 73 74 61 6e 64 61 72 |fined in| standar|
|00003230| 64 20 6d 6f 64 75 6c 65 | 0d 5c 63 6f 64 65 7b 73 |d module|.\code{s|
|00003240| 74 72 69 6e 67 7d 20 61 | 6e 64 20 69 6e 20 62 75 |tring} a|nd in bu|
|00003250| 69 6c 74 2d 69 6e 20 6d | 6f 64 75 6c 65 20 5c 63 |ilt-in m|odule \c|
|00003260| 6f 64 65 7b 72 65 67 65 | 78 7d 2e 0d 5c 69 6e 64 |ode{rege|x}..\ind|
|00003270| 65 78 7b 73 74 72 69 6e | 67 7d 0d 5c 69 6e 64 65 |ex{strin|g}.\inde|
|00003280| 78 7b 72 65 67 65 78 7d | 0d 0d 5c 73 75 62 73 75 |x{regex}|..\subsu|
|00003290| 62 73 65 63 74 69 6f 6e | 7b 4d 75 74 61 62 6c 65 |bsection|{Mutable|
|000032a0| 20 53 65 71 75 65 6e 63 | 65 20 54 79 70 65 73 2e | Sequenc|e Types.|
|000032b0| 7d 0d 0d 4c 69 73 74 20 | 6f 62 6a 65 63 74 73 20 |}..List |objects |
|000032c0| 73 75 70 70 6f 72 74 20 | 61 64 64 69 74 69 6f 6e |support |addition|
|000032d0| 61 6c 20 6f 70 65 72 61 | 74 69 6f 6e 73 20 74 68 |al opera|tions th|
|000032e0| 61 74 20 61 6c 6c 6f 77 | 20 69 6e 2d 70 6c 61 63 |at allow| in-plac|
|000032f0| 65 0d 6d 6f 64 69 66 69 | 63 61 74 69 6f 6e 20 6f |e.modifi|cation o|
|00003300| 66 20 74 68 65 20 6f 62 | 6a 65 63 74 2e 0d 54 68 |f the ob|ject..Th|
|00003310| 65 73 65 20 6f 70 65 72 | 61 74 69 6f 6e 73 20 77 |ese oper|ations w|
|00003320| 6f 75 6c 64 20 62 65 20 | 73 75 70 70 6f 72 74 65 |ould be |supporte|
|00003330| 64 20 62 79 20 6f 74 68 | 65 72 20 6d 75 74 61 62 |d by oth|er mutab|
|00003340| 6c 65 20 73 65 71 75 65 | 6e 63 65 20 74 79 70 65 |le seque|nce type|
|00003350| 73 0d 28 77 68 65 6e 20 | 61 64 64 65 64 20 74 6f |s.(when |added to|
|00003360| 20 74 68 65 20 6c 61 6e | 67 75 61 67 65 29 20 61 | the lan|guage) a|
|00003370| 73 20 77 65 6c 6c 2e 0d | 53 74 72 69 6e 67 73 20 |s well..|Strings |
|00003380| 61 6e 64 20 74 75 70 6c | 65 73 20 61 72 65 20 69 |and tupl|es are i|
|00003390| 6d 6d 75 74 61 62 6c 65 | 20 73 65 71 75 65 6e 63 |mmutable| sequenc|
|000033a0| 65 20 74 79 70 65 73 20 | 61 6e 64 20 73 75 63 68 |e types |and such|
|000033b0| 20 6f 62 6a 65 63 74 73 | 20 63 61 6e 6e 6f 74 0d | objects| cannot.|
|000033c0| 62 65 20 6d 6f 64 69 66 | 69 65 64 20 6f 6e 63 65 |be modif|ied once|
|000033d0| 20 63 72 65 61 74 65 64 | 2e 0d 54 68 65 20 66 6f | created|..The fo|
|000033e0| 6c 6c 6f 77 69 6e 67 20 | 6f 70 65 72 61 74 69 6f |llowing |operatio|
|000033f0| 6e 73 20 61 72 65 20 64 | 65 66 69 6e 65 64 20 6f |ns are d|efined o|
|00003400| 6e 20 6d 75 74 61 62 6c | 65 20 73 65 71 75 65 6e |n mutabl|e sequen|
|00003410| 63 65 20 74 79 70 65 73 | 20 28 77 68 65 72 65 0d |ce types| (where.|
|00003420| 5c 76 61 72 7b 78 7d 20 | 69 73 20 61 6e 20 61 72 |\var{x} |is an ar|
|00003430| 62 69 74 72 61 72 79 20 | 6f 62 6a 65 63 74 29 3a |bitrary |object):|
|00003440| 0d 5c 69 6e 64 65 78 69 | 69 69 7b 6d 75 74 61 62 |.\indexi|ii{mutab|
|00003450| 6c 65 7d 7b 73 65 71 75 | 65 6e 63 65 7d 7b 74 79 |le}{sequ|ence}{ty|
|00003460| 70 65 73 7d 0d 5c 69 6e | 64 65 78 69 69 7b 6c 69 |pes}.\in|dexii{li|
|00003470| 73 74 7d 7b 74 79 70 65 | 7d 0d 0d 5c 62 65 67 69 |st}{type|}..\begi|
|00003480| 6e 7b 74 61 62 6c 65 69 | 69 69 7d 7b 7c 63 7c 6c |n{tablei|ii}{|c|l|
|00003490| 7c 63 7c 7d 7b 63 6f 64 | 65 7d 7b 4f 70 65 72 61 ||c|}{cod|e}{Opera|
|000034a0| 74 69 6f 6e 7d 7b 52 65 | 73 75 6c 74 7d 7b 4e 6f |tion}{Re|sult}{No|
|000034b0| 74 65 73 7d 0d 20 20 5c | 6c 69 6e 65 69 69 69 7b |tes}. \|lineiii{|
|000034c0| 5c 76 61 72 7b 73 7d 5b | 5c 76 61 72 7b 69 7d 5d |\var{s}[|\var{i}]|
|000034d0| 20 3d 20 5c 76 61 72 7b | 78 7d 7d 0d 09 7b 69 74 | = \var{|x}}..{it|
|000034e0| 65 6d 20 5c 76 61 72 7b | 69 7d 20 6f 66 20 5c 76 |em \var{|i} of \v|
|000034f0| 61 72 7b 73 7d 20 69 73 | 20 72 65 70 6c 61 63 65 |ar{s} is| replace|
|00003500| 64 20 62 79 20 5c 76 61 | 72 7b 78 7d 7d 7b 7d 0d |d by \va|r{x}}{}.|
|00003510| 20 20 5c 6c 69 6e 65 69 | 69 69 7b 5c 76 61 72 7b | \linei|ii{\var{|
|00003520| 73 7d 5b 5c 76 61 72 7b | 69 7d 3a 5c 76 61 72 7b |s}[\var{|i}:\var{|
|00003530| 6a 7d 5d 20 3d 20 5c 76 | 61 72 7b 74 7d 7d 0d 20 |j}] = \v|ar{t}}. |
|00003540| 20 09 7b 73 6c 69 63 65 | 20 6f 66 20 5c 76 61 72 | .{slice| of \var|
|00003550| 7b 73 7d 20 66 72 6f 6d | 20 5c 76 61 72 7b 69 7d |{s} from| \var{i}|
|00003560| 20 74 6f 20 5c 76 61 72 | 7b 6a 7d 20 69 73 20 72 | to \var|{j} is r|
|00003570| 65 70 6c 61 63 65 64 20 | 62 79 20 5c 76 61 72 7b |eplaced |by \var{|
|00003580| 74 7d 7d 7b 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |t}}{}. |\lineiii|
|00003590| 7b 64 65 6c 20 5c 76 61 | 72 7b 73 7d 5b 5c 76 61 |{del \va|r{s}[\va|
|000035a0| 72 7b 69 7d 3a 5c 76 61 | 72 7b 6a 7d 5d 7d 0d 09 |r{i}:\va|r{j}]}..|
|000035b0| 7b 73 61 6d 65 20 61 73 | 20 5c 63 6f 64 65 7b 5c |{same as| \code{\|
|000035c0| 76 61 72 7b 73 7d 5b 5c | 76 61 72 7b 69 7d 3a 5c |var{s}[\|var{i}:\|
|000035d0| 76 61 72 7b 6a 7d 5d 20 | 3d 20 5b 5d 7d 7d 7b 7d |var{j}] |= []}}{}|
|000035e0| 0d 20 20 5c 6c 69 6e 65 | 69 69 69 7b 5c 76 61 72 |. \line|iii{\var|
|000035f0| 7b 73 7d 2e 61 70 70 65 | 6e 64 28 5c 76 61 72 7b |{s}.appe|nd(\var{|
|00003600| 78 7d 29 7d 0d 09 7b 73 | 61 6d 65 20 61 73 20 5c |x})}..{s|ame as \|
|00003610| 63 6f 64 65 7b 5c 76 61 | 72 7b 73 7d 5b 6c 65 6e |code{\va|r{s}[len|
|00003620| 28 5c 76 61 72 7b 73 7d | 29 3a 6c 65 6e 28 5c 76 |(\var{s}|):len(\v|
|00003630| 61 72 7b 73 7d 29 5d 20 | 3d 20 5b 5c 76 61 72 7b |ar{s})] |= [\var{|
|00003640| 78 7d 5d 7d 7d 7b 7d 0d | 20 20 5c 6c 69 6e 65 69 |x}]}}{}.| \linei|
|00003650| 69 69 7b 5c 76 61 72 7b | 73 7d 2e 63 6f 75 6e 74 |ii{\var{|s}.count|
|00003660| 28 5c 76 61 72 7b 78 7d | 29 7d 0d 09 7b 72 65 74 |(\var{x}|)}..{ret|
|00003670| 75 72 6e 20 6e 75 6d 62 | 65 72 20 6f 66 20 5c 76 |urn numb|er of \v|
|00003680| 61 72 7b 69 7d 27 73 20 | 66 6f 72 20 77 68 69 63 |ar{i}'s |for whic|
|00003690| 68 20 5c 63 6f 64 65 7b | 5c 76 61 72 7b 73 7d 5b |h \code{|\var{s}[|
|000036a0| 5c 76 61 72 7b 69 7d 5d | 20 3d 3d 20 5c 76 61 72 |\var{i}]| == \var|
|000036b0| 7b 78 7d 7d 7d 7b 7d 0d | 20 20 5c 6c 69 6e 65 69 |{x}}}{}.| \linei|
|000036c0| 69 69 7b 5c 76 61 72 7b | 73 7d 2e 69 6e 64 65 78 |ii{\var{|s}.index|
|000036d0| 28 5c 76 61 72 7b 78 7d | 29 7d 0d 09 7b 72 65 74 |(\var{x}|)}..{ret|
|000036e0| 75 72 6e 20 73 6d 61 6c | 6c 65 73 74 20 5c 76 61 |urn smal|lest \va|
|000036f0| 72 7b 69 7d 20 73 75 63 | 68 20 74 68 61 74 20 5c |r{i} suc|h that \|
|00003700| 63 6f 64 65 7b 5c 76 61 | 72 7b 73 7d 5b 5c 76 61 |code{\va|r{s}[\va|
|00003710| 72 7b 69 7d 5d 20 3d 3d | 20 5c 76 61 72 7b 78 7d |r{i}] ==| \var{x}|
|00003720| 7d 7d 7b 28 31 29 7d 0d | 20 20 5c 6c 69 6e 65 69 |}}{(1)}.| \linei|
|00003730| 69 69 7b 5c 76 61 72 7b | 73 7d 2e 69 6e 73 65 72 |ii{\var{|s}.inser|
|00003740| 74 28 5c 76 61 72 7b 69 | 7d 2c 20 5c 76 61 72 7b |t(\var{i|}, \var{|
|00003750| 78 7d 29 7d 0d 09 7b 73 | 61 6d 65 20 61 73 20 5c |x})}..{s|ame as \|
|00003760| 63 6f 64 65 7b 5c 76 61 | 72 7b 73 7d 5b 5c 76 61 |code{\va|r{s}[\va|
|00003770| 72 7b 69 7d 3a 5c 76 61 | 72 7b 69 7d 5d 20 3d 20 |r{i}:\va|r{i}] = |
|00003780| 5b 5c 76 61 72 7b 78 7d | 5d 7d 7d 7b 7d 0d 20 20 |[\var{x}|]}}{}. |
|00003790| 5c 6c 69 6e 65 69 69 69 | 7b 5c 76 61 72 7b 73 7d |\lineiii|{\var{s}|
|000037a0| 2e 72 65 6d 6f 76 65 28 | 5c 76 61 72 7b 78 7d 29 |.remove(|\var{x})|
|000037b0| 7d 0d 09 7b 73 61 6d 65 | 20 61 73 20 5c 63 6f 64 |}..{same| as \cod|
|000037c0| 65 7b 64 65 6c 20 5c 76 | 61 72 7b 73 7d 5b 5c 76 |e{del \v|ar{s}[\v|
|000037d0| 61 72 7b 73 7d 2e 69 6e | 64 65 78 28 5c 76 61 72 |ar{s}.in|dex(\var|
|000037e0| 7b 78 7d 29 5d 7d 7d 7b | 28 31 29 7d 0d 20 20 5c |{x})]}}{|(1)}. \|
|000037f0| 6c 69 6e 65 69 69 69 7b | 5c 76 61 72 7b 73 7d 2e |lineiii{|\var{s}.|
|00003800| 72 65 76 65 72 73 65 28 | 29 7d 0d 09 7b 72 65 76 |reverse(|)}..{rev|
|00003810| 65 72 73 65 73 20 74 68 | 65 20 69 74 65 6d 73 20 |erses th|e items |
|00003820| 6f 66 20 5c 76 61 72 7b | 73 7d 20 69 6e 20 70 6c |of \var{|s} in pl|
|00003830| 61 63 65 7d 7b 7d 0d 20 | 20 5c 6c 69 6e 65 69 69 |ace}{}. | \lineii|
|00003840| 69 7b 5c 76 61 72 7b 73 | 7d 2e 73 6f 72 74 28 29 |i{\var{s|}.sort()|
|00003850| 7d 0d 09 7b 70 65 72 6d | 75 74 65 73 20 74 68 65 |}..{perm|utes the|
|00003860| 20 69 74 65 6d 73 20 6f | 66 20 5c 76 61 72 7b 73 | items o|f \var{s|
|00003870| 7d 20 74 6f 20 73 61 74 | 69 73 66 79 0d 20 20 20 |} to sat|isfy. |
|00003880| 20 20 20 20 20 5c 63 6f | 64 65 7b 5c 76 61 72 7b | \co|de{\var{|
|00003890| 73 7d 5b 5c 76 61 72 7b | 69 7d 5d 20 3c 3d 20 5c |s}[\var{|i}] <= \|
|000038a0| 76 61 72 7b 73 7d 5b 5c | 76 61 72 7b 6a 7d 5d 7d |var{s}[\|var{j}]}|
|000038b0| 2c 0d 20 20 20 20 20 20 | 20 20 66 6f 72 20 5c 63 |,. | for \c|
|000038c0| 6f 64 65 7b 5c 76 61 72 | 7b 69 7d 20 3c 20 5c 76 |ode{\var|{i} < \v|
|000038d0| 61 72 7b 6a 7d 7d 7d 7b | 28 32 29 7d 0d 5c 65 6e |ar{j}}}{|(2)}.\en|
|000038e0| 64 7b 74 61 62 6c 65 69 | 69 69 7d 0d 5c 69 6e 64 |d{tablei|ii}.\ind|
|000038f0| 65 78 69 76 7b 6f 70 65 | 72 61 74 69 6f 6e 73 20 |exiv{ope|rations |
|00003900| 6f 6e 7d 7b 6d 75 74 61 | 62 6c 65 7d 7b 73 65 71 |on}{muta|ble}{seq|
|00003910| 75 65 6e 63 65 7d 7b 74 | 79 70 65 73 7d 0d 5c 69 |uence}{t|ypes}.\i|
|00003920| 6e 64 65 78 69 69 69 7b | 6f 70 65 72 61 74 69 6f |ndexiii{|operatio|
|00003930| 6e 73 20 6f 6e 7d 7b 73 | 65 71 75 65 6e 63 65 7d |ns on}{s|equence}|
|00003940| 7b 74 79 70 65 73 7d 0d | 5c 69 6e 64 65 78 69 69 |{types}.|\indexii|
|00003950| 69 7b 6f 70 65 72 61 74 | 69 6f 6e 73 20 6f 6e 7d |i{operat|ions on}|
|00003960| 7b 6c 69 73 74 7d 7b 74 | 79 70 65 7d 0d 5c 69 6e |{list}{t|ype}.\in|
|00003970| 64 65 78 69 69 7b 73 75 | 62 73 63 72 69 70 74 7d |dexii{su|bscript}|
|00003980| 7b 61 73 73 69 67 6e 6d | 65 6e 74 7d 0d 5c 69 6e |{assignm|ent}.\in|
|00003990| 64 65 78 69 69 7b 73 6c | 69 63 65 7d 7b 61 73 73 |dexii{sl|ice}{ass|
|000039a0| 69 67 6e 6d 65 6e 74 7d | 0d 5c 73 74 69 6e 64 65 |ignment}|.\stinde|
|000039b0| 78 7b 64 65 6c 7d 0d 5c | 72 65 6e 65 77 63 6f 6d |x{del}.\|renewcom|
|000039c0| 6d 61 6e 64 7b 5c 69 6e | 64 65 78 73 75 62 69 74 |mand{\in|dexsubit|
|000039d0| 65 6d 7d 7b 28 6c 69 73 | 74 20 6d 65 74 68 6f 64 |em}{(lis|t method|
|000039e0| 29 7d 0d 5c 74 74 69 6e | 64 65 78 7b 61 70 70 65 |)}.\ttin|dex{appe|
|000039f0| 6e 64 7d 0d 5c 74 74 69 | 6e 64 65 78 7b 63 6f 75 |nd}.\tti|ndex{cou|
|00003a00| 6e 74 7d 0d 5c 74 74 69 | 6e 64 65 78 7b 69 6e 64 |nt}.\tti|ndex{ind|
|00003a10| 65 78 7d 0d 5c 74 74 69 | 6e 64 65 78 7b 69 6e 73 |ex}.\tti|ndex{ins|
|00003a20| 65 72 74 7d 0d 5c 74 74 | 69 6e 64 65 78 7b 72 65 |ert}.\tt|index{re|
|00003a30| 6d 6f 76 65 7d 0d 5c 74 | 74 69 6e 64 65 78 7b 72 |move}.\t|tindex{r|
|00003a40| 65 76 65 72 73 65 7d 0d | 5c 74 74 69 6e 64 65 78 |everse}.|\ttindex|
|00003a50| 7b 73 6f 72 74 7d 0d 0d | 5c 6e 6f 69 6e 64 65 6e |{sort}..|\noinden|
|00003a60| 74 0d 4e 6f 74 65 73 3a | 0d 5c 62 65 67 69 6e 7b |t.Notes:|.\begin{|
|00003a70| 64 65 73 63 72 69 70 74 | 69 6f 6e 7d 0d 5c 69 74 |descript|ion}.\it|
|00003a80| 65 6d 5b 28 31 29 5d 20 | 52 61 69 73 65 73 20 61 |em[(1)] |Raises a|
|00003a90| 6e 20 65 78 63 65 70 74 | 69 6f 6e 20 77 68 65 6e |n except|ion when|
|00003aa0| 20 5c 76 61 72 7b 78 7d | 20 69 73 20 6e 6f 74 20 | \var{x}| is not |
|00003ab0| 66 6f 75 6e 64 20 69 6e | 20 5c 76 61 72 7b 73 7d |found in| \var{s}|
|00003ac0| 2e 0d 20 20 0d 5c 69 74 | 65 6d 5b 28 32 29 5d 20 |.. .\it|em[(2)] |
|00003ad0| 54 68 65 20 5c 63 6f 64 | 65 7b 73 6f 72 74 28 29 |The \cod|e{sort()|
|00003ae0| 7d 20 6d 65 74 68 6f 64 | 20 74 61 6b 65 73 20 61 |} method| takes a|
|00003af0| 6e 20 6f 70 74 69 6f 6e | 61 6c 20 61 72 67 75 6d |n option|al argum|
|00003b00| 65 6e 74 0d 20 20 73 70 | 65 63 69 66 79 69 6e 67 |ent. sp|ecifying|
|00003b10| 20 61 20 63 6f 6d 70 61 | 72 69 73 6f 6e 20 66 75 | a compa|rison fu|
|00003b20| 6e 63 74 69 6f 6e 20 6f | 66 20 74 77 6f 20 61 72 |nction o|f two ar|
|00003b30| 67 75 6d 65 6e 74 73 20 | 28 6c 69 73 74 20 69 74 |guments |(list it|
|00003b40| 65 6d 73 29 20 77 68 69 | 63 68 0d 20 20 73 68 6f |ems) whi|ch. sho|
|00003b50| 75 6c 64 20 72 65 74 75 | 72 6e 20 5c 63 6f 64 65 |uld retu|rn \code|
|00003b60| 7b 2d 31 7d 2c 20 5c 63 | 6f 64 65 7b 30 7d 20 6f |{-1}, \c|ode{0} o|
|00003b70| 72 20 5c 63 6f 64 65 7b | 31 7d 20 64 65 70 65 6e |r \code{|1} depen|
|00003b80| 64 69 6e 67 20 6f 6e 20 | 77 68 65 74 68 65 72 20 |ding on |whether |
|00003b90| 74 68 65 0d 20 20 66 69 | 72 73 74 20 61 72 67 75 |the. fi|rst argu|
|00003ba0| 6d 65 6e 74 20 69 73 20 | 63 6f 6e 73 69 64 65 72 |ment is |consider|
|00003bb0| 65 64 20 73 6d 61 6c 6c | 65 72 20 74 68 61 6e 2c |ed small|er than,|
|00003bc0| 20 65 71 75 61 6c 20 74 | 6f 2c 20 6f 72 20 6c 61 | equal t|o, or la|
|00003bd0| 72 67 65 72 20 74 68 61 | 6e 20 74 68 65 0d 20 20 |rger tha|n the. |
|00003be0| 73 65 63 6f 6e 64 20 61 | 72 67 75 6d 65 6e 74 2e |second a|rgument.|
|00003bf0| 20 20 4e 6f 74 65 20 74 | 68 61 74 20 74 68 69 73 | Note t|hat this|
|00003c00| 20 73 6c 6f 77 73 20 74 | 68 65 20 73 6f 72 74 69 | slows t|he sorti|
|00003c10| 6e 67 20 70 72 6f 63 65 | 73 73 20 64 6f 77 6e 0d |ng proce|ss down.|
|00003c20| 20 20 63 6f 6e 73 69 64 | 65 72 61 62 6c 79 3b 20 | consid|erably; |
|00003c30| 65 2e 67 2e 20 74 6f 20 | 73 6f 72 74 20 61 6e 20 |e.g. to |sort an |
|00003c40| 61 72 72 61 79 20 69 6e | 20 72 65 76 65 72 73 65 |array in| reverse|
|00003c50| 20 6f 72 64 65 72 20 69 | 74 20 69 73 20 6d 75 63 | order i|t is muc|
|00003c60| 68 20 66 61 73 74 65 72 | 0d 20 20 74 6f 20 75 73 |h faster|. to us|
|00003c70| 65 20 63 61 6c 6c 73 20 | 74 6f 20 5c 63 6f 64 65 |e calls |to \code|
|00003c80| 7b 73 6f 72 74 28 29 7d | 20 61 6e 64 20 5c 63 6f |{sort()}| and \co|
|00003c90| 64 65 7b 72 65 76 65 72 | 73 65 28 29 7d 20 74 68 |de{rever|se()} th|
|00003ca0| 61 6e 20 74 6f 20 75 73 | 65 0d 20 20 5c 63 6f 64 |an to us|e. \cod|
|00003cb0| 65 7b 73 6f 72 74 28 29 | 7d 20 77 69 74 68 20 61 |e{sort()|} with a|
|00003cc0| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 66 75 6e 63 | compari|son func|
|00003cd0| 74 69 6f 6e 20 74 68 61 | 74 20 72 65 76 65 72 73 |tion tha|t revers|
|00003ce0| 65 73 20 74 68 65 20 6f | 72 64 65 72 69 6e 67 20 |es the o|rdering |
|00003cf0| 6f 66 0d 20 20 74 68 65 | 20 65 6c 65 6d 65 6e 74 |of. the| element|
|00003d00| 73 2e 0d 5c 65 6e 64 7b | 64 65 73 63 72 69 70 74 |s..\end{|descript|
|00003d10| 69 6f 6e 7d 0d 0d 5c 73 | 75 62 73 65 63 74 69 6f |ion}..\s|ubsectio|
|00003d20| 6e 7b 4d 61 70 70 69 6e | 67 20 54 79 70 65 73 7d |n{Mappin|g Types}|
|00003d30| 0d 0d 41 20 5c 64 66 6e | 7b 6d 61 70 70 69 6e 67 |..A \dfn|{mapping|
|00003d40| 7d 20 6f 62 6a 65 63 74 | 20 6d 61 70 73 20 76 61 |} object| maps va|
|00003d50| 6c 75 65 73 20 6f 66 20 | 6f 6e 65 20 74 79 70 65 |lues of |one type|
|00003d60| 20 28 74 68 65 20 6b 65 | 79 20 74 79 70 65 29 20 | (the ke|y type) |
|00003d70| 74 6f 0d 61 72 62 69 74 | 72 61 72 79 20 6f 62 6a |to.arbit|rary obj|
|00003d80| 65 63 74 73 2e 20 20 4d | 61 70 70 69 6e 67 73 20 |ects. M|appings |
|00003d90| 61 72 65 20 6d 75 74 61 | 62 6c 65 20 6f 62 6a 65 |are muta|ble obje|
|00003da0| 63 74 73 2e 20 20 54 68 | 65 72 65 20 69 73 20 63 |cts. Th|ere is c|
|00003db0| 75 72 72 65 6e 74 6c 79 | 0d 6f 6e 6c 79 20 6f 6e |urrently|.only on|
|00003dc0| 65 20 6d 61 70 70 69 6e | 67 20 74 79 70 65 2c 20 |e mappin|g type, |
|00003dd0| 74 68 65 20 5c 64 66 6e | 7b 64 69 63 74 69 6f 6e |the \dfn|{diction|
|00003de0| 61 72 79 7d 2e 20 20 41 | 20 64 69 63 74 69 6f 6e |ary}. A| diction|
|00003df0| 61 72 79 27 73 20 6b 65 | 79 73 20 61 72 65 0d 61 |ary's ke|ys are.a|
|00003e00| 6c 6d 6f 73 74 20 61 72 | 62 69 74 72 61 72 79 20 |lmost ar|bitrary |
|00003e10| 76 61 6c 75 65 73 2e 20 | 20 54 68 65 20 6f 6e 6c |values. | The onl|
|00003e20| 79 20 74 79 70 65 73 20 | 6f 66 20 76 61 6c 75 65 |y types |of value|
|00003e30| 73 20 6e 6f 74 20 61 63 | 63 65 70 74 61 62 6c 65 |s not ac|ceptable|
|00003e40| 20 61 73 0d 6b 65 79 73 | 20 61 72 65 20 76 61 6c | as.keys| are val|
|00003e50| 75 65 73 20 63 6f 6e 74 | 61 69 6e 69 6e 67 20 6c |ues cont|aining l|
|00003e60| 69 73 74 73 20 6f 72 20 | 64 69 63 74 69 6f 6e 61 |ists or |dictiona|
|00003e70| 72 69 65 73 20 6f 72 20 | 6f 74 68 65 72 20 6d 75 |ries or |other mu|
|00003e80| 74 61 62 6c 65 0d 74 79 | 70 65 73 20 74 68 61 74 |table.ty|pes that|
|00003e90| 20 61 72 65 20 63 6f 6d | 70 61 72 65 64 20 62 79 | are com|pared by|
|00003ea0| 20 76 61 6c 75 65 20 72 | 61 74 68 65 72 20 74 68 | value r|ather th|
|00003eb0| 61 6e 20 62 79 20 6f 62 | 6a 65 63 74 20 69 64 65 |an by ob|ject ide|
|00003ec0| 6e 74 69 74 79 2e 0d 4e | 75 6d 65 72 69 63 20 74 |ntity..N|umeric t|
|00003ed0| 79 70 65 73 20 75 73 65 | 64 20 66 6f 72 20 6b 65 |ypes use|d for ke|
|00003ee0| 79 73 20 6f 62 65 79 20 | 74 68 65 20 6e 6f 72 6d |ys obey |the norm|
|00003ef0| 61 6c 20 72 75 6c 65 73 | 20 66 6f 72 20 6e 75 6d |al rules| for num|
|00003f00| 65 72 69 63 0d 63 6f 6d | 70 61 72 69 73 6f 6e 3a |eric.com|parison:|
|00003f10| 20 69 66 20 74 77 6f 20 | 6e 75 6d 62 65 72 73 20 | if two |numbers |
|00003f20| 63 6f 6d 70 61 72 65 20 | 65 71 75 61 6c 20 28 65 |compare |equal (e|
|00003f30| 2e 67 2e 20 31 20 61 6e | 64 20 31 2e 30 29 20 74 |.g. 1 an|d 1.0) t|
|00003f40| 68 65 6e 20 74 68 65 79 | 0d 63 61 6e 20 62 65 20 |hen they|.can be |
|00003f50| 75 73 65 64 20 69 6e 74 | 65 72 63 68 61 6e 67 65 |used int|erchange|
|00003f60| 61 62 6c 79 20 74 6f 20 | 69 6e 64 65 78 20 74 68 |ably to |index th|
|00003f70| 65 20 73 61 6d 65 20 64 | 69 63 74 69 6f 6e 61 72 |e same d|ictionar|
|00003f80| 79 20 65 6e 74 72 79 2e | 0d 0d 5c 69 6e 64 65 78 |y entry.|..\index|
|00003f90| 69 69 7b 6d 61 70 70 69 | 6e 67 7d 7b 74 79 70 65 |ii{mappi|ng}{type|
|00003fa0| 73 7d 0d 5c 69 6e 64 65 | 78 69 69 7b 64 69 63 74 |s}.\inde|xii{dict|
|00003fb0| 69 6f 6e 61 72 79 7d 7b | 74 79 70 65 7d 0d 0d 44 |ionary}{|type}..D|
|00003fc0| 69 63 74 69 6f 6e 61 72 | 69 65 73 20 61 72 65 20 |ictionar|ies are |
|00003fd0| 63 72 65 61 74 65 64 20 | 62 79 20 70 6c 61 63 69 |created |by placi|
|00003fe0| 6e 67 20 61 20 63 6f 6d | 6d 61 2d 73 65 70 61 72 |ng a com|ma-separ|
|00003ff0| 61 74 65 64 20 6c 69 73 | 74 20 6f 66 0d 5c 63 6f |ated lis|t of.\co|
|00004000| 64 65 7b 5c 76 61 72 7b | 6b 65 79 7d 3a 20 5c 76 |de{\var{|key}: \v|
|00004010| 61 72 7b 76 61 6c 75 65 | 7d 7d 20 70 61 69 72 73 |ar{value|}} pairs|
|00004020| 20 77 69 74 68 69 6e 20 | 62 72 61 63 65 73 2c 20 | within |braces, |
|00004030| 66 6f 72 20 65 78 61 6d | 70 6c 65 3a 0d 5c 63 6f |for exam|ple:.\co|
|00004040| 64 65 7b 5c 7b 27 6a 61 | 63 6b 27 3a 20 34 30 39 |de{\{'ja|ck': 409|
|00004050| 38 2c 20 27 73 6a 6f 65 | 72 64 3a 20 34 31 32 37 |8, 'sjoe|rd: 4127|
|00004060| 5c 7d 7d 20 6f 72 0d 5c | 63 6f 64 65 7b 5c 7b 34 |\}} or.\|code{\{4|
|00004070| 30 39 38 3a 20 27 6a 61 | 63 6b 27 2c 20 34 31 32 |098: 'ja|ck', 412|
|00004080| 37 3a 20 27 73 6a 6f 65 | 72 64 5c 7d 7d 2e 0d 0d |7: 'sjoe|rd\}}...|
|00004090| 54 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 6f 70 |The foll|owing op|
|000040a0| 65 72 61 74 69 6f 6e 73 | 20 61 72 65 20 64 65 66 |erations| are def|
|000040b0| 69 6e 65 64 20 6f 6e 20 | 6d 61 70 70 69 6e 67 73 |ined on |mappings|
|000040c0| 20 28 77 68 65 72 65 20 | 5c 76 61 72 7b 61 7d 20 | (where |\var{a} |
|000040d0| 69 73 20 61 0d 6d 61 70 | 70 69 6e 67 2c 20 5c 76 |is a.map|ping, \v|
|000040e0| 61 72 7b 6b 7d 20 69 73 | 20 61 20 6b 65 79 20 61 |ar{k} is| a key a|
|000040f0| 6e 64 20 5c 76 61 72 7b | 78 7d 20 69 73 20 61 6e |nd \var{|x} is an|
|00004100| 20 61 72 62 69 74 72 61 | 72 79 20 6f 62 6a 65 63 | arbitra|ry objec|
|00004110| 74 29 3a 0d 0d 5c 62 65 | 67 69 6e 7b 74 61 62 6c |t):..\be|gin{tabl|
|00004120| 65 69 69 69 7d 7b 7c 63 | 7c 6c 7c 63 7c 7d 7b 63 |eiii}{|c||l|c|}{c|
|00004130| 6f 64 65 7d 7b 4f 70 65 | 72 61 74 69 6f 6e 7d 7b |ode}{Ope|ration}{|
|00004140| 52 65 73 75 6c 74 7d 7b | 4e 6f 74 65 73 7d 0d 20 |Result}{|Notes}. |
|00004150| 20 5c 6c 69 6e 65 69 69 | 69 7b 6c 65 6e 28 5c 76 | \lineii|i{len(\v|
|00004160| 61 72 7b 61 7d 29 7d 7b | 74 68 65 20 6e 75 6d 62 |ar{a})}{|the numb|
|00004170| 65 72 20 6f 66 20 69 74 | 65 6d 73 20 69 6e 20 5c |er of it|ems in \|
|00004180| 76 61 72 7b 61 7d 7d 7b | 7d 0d 20 20 5c 6c 69 6e |var{a}}{|}. \lin|
|00004190| 65 69 69 69 7b 5c 76 61 | 72 7b 61 7d 5b 5c 76 61 |eiii{\va|r{a}[\va|
|000041a0| 72 7b 6b 7d 5d 7d 7b 74 | 68 65 20 69 74 65 6d 20 |r{k}]}{t|he item |
|000041b0| 6f 66 20 5c 76 61 72 7b | 61 7d 20 77 69 74 68 20 |of \var{|a} with |
|000041c0| 6b 65 79 20 5c 76 61 72 | 7b 6b 7d 7d 7b 28 31 29 |key \var|{k}}{(1)|
|000041d0| 7d 0d 20 20 5c 6c 69 6e | 65 69 69 69 7b 5c 76 61 |}. \lin|eiii{\va|
|000041e0| 72 7b 61 7d 5b 5c 76 61 | 72 7b 6b 7d 5d 20 3d 20 |r{a}[\va|r{k}] = |
|000041f0| 5c 76 61 72 7b 78 7d 7d | 7b 73 65 74 20 5c 63 6f |\var{x}}|{set \co|
|00004200| 64 65 7b 5c 76 61 72 7b | 61 7d 5b 5c 76 61 72 7b |de{\var{|a}[\var{|
|00004210| 6b 7d 5d 7d 20 74 6f 20 | 5c 76 61 72 7b 78 7d 7d |k}]} to |\var{x}}|
|00004220| 7b 7d 0d 20 20 5c 6c 69 | 6e 65 69 69 69 7b 64 65 |{}. \li|neiii{de|
|00004230| 6c 20 5c 76 61 72 7b 61 | 7d 5b 5c 76 61 72 7b 6b |l \var{a|}[\var{k|
|00004240| 7d 5d 7d 7b 72 65 6d 6f | 76 65 20 5c 63 6f 64 65 |}]}{remo|ve \code|
|00004250| 7b 5c 76 61 72 7b 61 7d | 5b 5c 76 61 72 7b 6b 7d |{\var{a}|[\var{k}|
|00004260| 5d 7d 20 66 72 6f 6d 20 | 5c 76 61 72 7b 61 7d 7d |]} from |\var{a}}|
|00004270| 7b 28 31 29 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |{(1)}. |\lineiii|
|00004280| 7b 5c 76 61 72 7b 61 7d | 2e 69 74 65 6d 73 28 29 |{\var{a}|.items()|
|00004290| 7d 7b 61 20 63 6f 70 79 | 20 6f 66 20 5c 76 61 72 |}{a copy| of \var|
|000042a0| 7b 61 7d 27 73 20 6c 69 | 73 74 20 6f 66 20 28 6b |{a}'s li|st of (k|
|000042b0| 65 79 2c 20 69 74 65 6d | 29 20 70 61 69 72 73 7d |ey, item|) pairs}|
|000042c0| 7b 28 32 29 7d 0d 20 20 | 5c 6c 69 6e 65 69 69 69 |{(2)}. |\lineiii|
|000042d0| 7b 5c 76 61 72 7b 61 7d | 2e 6b 65 79 73 28 29 7d |{\var{a}|.keys()}|
|000042e0| 7b 61 20 63 6f 70 79 20 | 6f 66 20 5c 76 61 72 7b |{a copy |of \var{|
|000042f0| 61 7d 27 73 20 6c 69 73 | 74 20 6f 66 20 6b 65 79 |a}'s lis|t of key|
|00004300| 73 7d 7b 28 32 29 7d 0d | 20 20 5c 6c 69 6e 65 69 |s}{(2)}.| \linei|
|00004310| 69 69 7b 5c 76 61 72 7b | 61 7d 2e 76 61 6c 75 65 |ii{\var{|a}.value|
|00004320| 73 28 29 7d 7b 61 20 63 | 6f 70 79 20 6f 66 20 5c |s()}{a c|opy of \|
|00004330| 76 61 72 7b 61 7d 27 73 | 20 6c 69 73 74 20 6f 66 |var{a}'s| list of|
|00004340| 20 76 61 6c 75 65 73 7d | 7b 28 32 29 7d 0d 20 20 | values}|{(2)}. |
|00004350| 5c 6c 69 6e 65 69 69 69 | 7b 5c 76 61 72 7b 61 7d |\lineiii|{\var{a}|
|00004360| 2e 68 61 73 5f 6b 65 79 | 28 5c 76 61 72 7b 6b 7d |.has_key|(\var{k}|
|00004370| 29 7d 7b 5c 63 6f 64 65 | 7b 31 7d 20 69 66 20 5c |)}{\code|{1} if \|
|00004380| 76 61 72 7b 61 7d 20 68 | 61 73 20 61 20 6b 65 79 |var{a} h|as a key|
|00004390| 20 5c 76 61 72 7b 6b 7d | 2c 20 65 6c 73 65 20 5c | \var{k}|, else \|
|000043a0| 63 6f 64 65 7b 30 7d 7d | 7b 7d 0d 5c 65 6e 64 7b |code{0}}|{}.\end{|
|000043b0| 74 61 62 6c 65 69 69 69 | 7d 0d 5c 69 6e 64 65 78 |tableiii|}.\index|
|000043c0| 69 69 69 7b 6f 70 65 72 | 61 74 69 6f 6e 73 20 6f |iii{oper|ations o|
|000043d0| 6e 7d 7b 6d 61 70 70 69 | 6e 67 7d 7b 74 79 70 65 |n}{mappi|ng}{type|
|000043e0| 73 7d 0d 5c 69 6e 64 65 | 78 69 69 69 7b 6f 70 65 |s}.\inde|xiii{ope|
|000043f0| 72 61 74 69 6f 6e 73 20 | 6f 6e 7d 7b 64 69 63 74 |rations |on}{dict|
|00004400| 69 6f 6e 61 72 79 7d 7b | 74 79 70 65 7d 0d 5c 73 |ionary}{|type}.\s|
|00004410| 74 69 6e 64 65 78 7b 64 | 65 6c 7d 0d 5c 62 69 66 |tindex{d|el}.\bif|
|00004420| 75 6e 63 69 6e 64 65 78 | 7b 6c 65 6e 7d 0d 5c 72 |uncindex|{len}.\r|
|00004430| 65 6e 65 77 63 6f 6d 6d | 61 6e 64 7b 5c 69 6e 64 |enewcomm|and{\ind|
|00004440| 65 78 73 75 62 69 74 65 | 6d 7d 7b 28 64 69 63 74 |exsubite|m}{(dict|
|00004450| 69 6f 6e 61 72 79 20 6d | 65 74 68 6f 64 29 7d 0d |ionary m|ethod)}.|
|00004460| 5c 74 74 69 6e 64 65 78 | 7b 6b 65 79 73 7d 0d 5c |\ttindex|{keys}.\|
|00004470| 74 74 69 6e 64 65 78 7b | 68 61 73 5f 6b 65 79 7d |ttindex{|has_key}|
|00004480| 0d 0d 25 20 58 58 58 4a | 48 20 73 6f 6d 65 20 6c |..% XXXJ|H some l|
|00004490| 69 6e 65 73 20 61 62 6f | 76 65 2c 20 79 6f 75 20 |ines abo|ve, you |
|000044a0| 74 61 6c 6b 20 61 62 6f | 75 74 20 60 74 72 75 65 |talk abo|ut `true|
|000044b0| 27 2c 20 65 6c 73 65 77 | 68 65 72 65 20 79 6f 75 |', elsew|here you|
|000044c0| 0d 25 20 65 78 70 6c 69 | 63 69 74 65 6c 79 20 73 |.% expli|citely s|
|000044d0| 74 61 74 65 73 20 5c 63 | 6f 64 65 7b 30 7d 20 6f |tates \c|ode{0} o|
|000044e0| 72 20 5c 63 6f 64 65 7b | 31 7d 2e 0d 5c 6e 6f 69 |r \code{|1}..\noi|
|000044f0| 6e 64 65 6e 74 0d 4e 6f | 74 65 73 3a 0d 5c 62 65 |ndent.No|tes:.\be|
|00004500| 67 69 6e 7b 64 65 73 63 | 72 69 70 74 69 6f 6e 7d |gin{desc|ription}|
|00004510| 0d 5c 69 74 65 6d 5b 28 | 31 29 5d 20 52 61 69 73 |.\item[(|1)] Rais|
|00004520| 65 73 20 61 6e 20 65 78 | 63 65 70 74 69 6f 6e 20 |es an ex|ception |
|00004530| 69 66 20 5c 76 61 72 7b | 6b 7d 20 69 73 20 6e 6f |if \var{|k} is no|
|00004540| 74 20 69 6e 20 74 68 65 | 20 6d 61 70 2e 0d 0d 5c |t in the| map...\|
|00004550| 69 74 65 6d 5b 28 32 29 | 5d 20 4b 65 79 73 20 61 |item[(2)|] Keys a|
|00004560| 6e 64 20 76 61 6c 75 65 | 73 20 61 72 65 20 6c 69 |nd value|s are li|
|00004570| 73 74 65 64 20 69 6e 20 | 72 61 6e 64 6f 6d 20 6f |sted in |random o|
|00004580| 72 64 65 72 2c 20 62 75 | 74 20 61 74 20 61 6e 79 |rder, bu|t at any|
|00004590| 0d 6d 6f 6d 65 6e 74 20 | 74 68 65 20 6f 72 64 65 |.moment |the orde|
|000045a0| 72 69 6e 67 20 6f 66 20 | 74 68 65 20 5c 63 6f 64 |ring of |the \cod|
|000045b0| 65 7b 6b 65 79 73 28 29 | 7d 2c 20 5c 63 6f 64 65 |e{keys()|}, \code|
|000045c0| 7b 76 61 6c 75 65 73 28 | 29 7d 20 61 6e 64 0d 5c |{values(|)} and.\|
|000045d0| 63 6f 64 65 7b 69 74 65 | 6d 73 28 29 7d 20 6c 69 |code{ite|ms()} li|
|000045e0| 73 74 73 20 69 73 20 74 | 68 65 20 63 6f 6e 73 69 |sts is t|he consi|
|000045f0| 73 74 65 6e 74 20 77 69 | 74 68 20 65 61 63 68 20 |stent wi|th each |
|00004600| 6f 74 68 65 72 2e 0d 5c | 65 6e 64 7b 64 65 73 63 |other..\|end{desc|
|00004610| 72 69 70 74 69 6f 6e 7d | 0d 0d 5c 73 75 62 73 65 |ription}|..\subse|
|00004620| 63 74 69 6f 6e 7b 4f 74 | 68 65 72 20 42 75 69 6c |ction{Ot|her Buil|
|00004630| 74 2d 69 6e 20 54 79 70 | 65 73 7d 0d 0d 54 68 65 |t-in Typ|es}..The|
|00004640| 20 69 6e 74 65 72 70 72 | 65 74 65 72 20 73 75 70 | interpr|eter sup|
|00004650| 70 6f 72 74 73 20 73 65 | 76 65 72 61 6c 20 6f 74 |ports se|veral ot|
|00004660| 68 65 72 20 6b 69 6e 64 | 73 20 6f 66 20 6f 62 6a |her kind|s of obj|
|00004670| 65 63 74 73 2e 0d 4d 6f | 73 74 20 6f 66 20 74 68 |ects..Mo|st of th|
|00004680| 65 73 65 20 73 75 70 70 | 6f 72 74 20 6f 6e 6c 79 |ese supp|ort only|
|00004690| 20 6f 6e 65 20 6f 72 20 | 74 77 6f 20 6f 70 65 72 | one or |two oper|
|000046a0| 61 74 69 6f 6e 73 2e 0d | 0d 5c 73 75 62 73 75 62 |ations..|.\subsub|
|000046b0| 73 65 63 74 69 6f 6e 7b | 4d 6f 64 75 6c 65 73 2e |section{|Modules.|
|000046c0| 7d 0d 0d 54 68 65 20 6f | 6e 6c 79 20 73 70 65 63 |}..The o|nly spec|
|000046d0| 69 61 6c 20 6f 70 65 72 | 61 74 69 6f 6e 20 6f 6e |ial oper|ation on|
|000046e0| 20 61 20 6d 6f 64 75 6c | 65 20 69 73 20 61 74 74 | a modul|e is att|
|000046f0| 72 69 62 75 74 65 20 61 | 63 63 65 73 73 3a 0d 5c |ribute a|ccess:.\|
|00004700| 63 6f 64 65 7b 5c 76 61 | 72 7b 6d 7d 2e 5c 76 61 |code{\va|r{m}.\va|
|00004710| 72 7b 6e 61 6d 65 7d 7d | 2c 20 77 68 65 72 65 20 |r{name}}|, where |
|00004720| 5c 76 61 72 7b 6d 7d 20 | 69 73 20 61 20 6d 6f 64 |\var{m} |is a mod|
|00004730| 75 6c 65 20 61 6e 64 20 | 5c 76 61 72 7b 6e 61 6d |ule and |\var{nam|
|00004740| 65 7d 20 61 63 63 65 73 | 73 65 73 0d 61 20 6e 61 |e} acces|ses.a na|
|00004750| 6d 65 20 64 65 66 69 6e | 65 64 20 69 6e 20 5c 76 |me defin|ed in \v|
|00004760| 61 72 7b 6d 7d 27 73 20 | 73 79 6d 62 6f 6c 20 74 |ar{m}'s |symbol t|
|00004770| 61 62 6c 65 2e 20 20 4d | 6f 64 75 6c 65 20 61 74 |able. M|odule at|
|00004780| 74 72 69 62 75 74 65 73 | 20 63 61 6e 20 62 65 0d |tributes| can be.|
|00004790| 61 73 73 69 67 6e 65 64 | 20 74 6f 2e 20 20 28 4e |assigned| to. (N|
|000047a0| 6f 74 65 20 74 68 61 74 | 20 74 68 65 20 5c 63 6f |ote that| the \co|
|000047b0| 64 65 7b 69 6d 70 6f 72 | 74 7d 20 73 74 61 74 65 |de{impor|t} state|
|000047c0| 6d 65 6e 74 20 69 73 20 | 6e 6f 74 2c 20 73 74 72 |ment is |not, str|
|000047d0| 69 63 74 6c 79 0d 73 70 | 6f 6b 65 6e 2c 20 61 6e |ictly.sp|oken, an|
|000047e0| 20 6f 70 65 72 61 74 69 | 6f 6e 20 6f 6e 20 61 20 | operati|on on a |
|000047f0| 6d 6f 64 75 6c 65 20 6f | 62 6a 65 63 74 3b 20 5c |module o|bject; \|
|00004800| 63 6f 64 65 7b 69 6d 70 | 6f 72 74 20 5c 76 61 72 |code{imp|ort \var|
|00004810| 7b 66 6f 6f 7d 7d 20 64 | 6f 65 73 20 6e 6f 74 0d |{foo}} d|oes not.|
|00004820| 72 65 71 75 69 72 65 20 | 61 20 6d 6f 64 75 6c 65 |require |a module|
|00004830| 20 6f 62 6a 65 63 74 20 | 6e 61 6d 65 64 20 5c 76 | object |named \v|
|00004840| 61 72 7b 66 6f 6f 7d 20 | 74 6f 20 65 78 69 73 74 |ar{foo} |to exist|
|00004850| 2c 20 72 61 74 68 65 72 | 20 69 74 20 72 65 71 75 |, rather| it requ|
|00004860| 69 72 65 73 0d 61 6e 20 | 28 65 78 74 65 72 6e 61 |ires.an |(externa|
|00004870| 6c 29 20 5c 65 6d 70 68 | 7b 64 65 66 69 6e 69 74 |l) \emph|{definit|
|00004880| 69 6f 6e 7d 20 66 6f 72 | 20 61 20 6d 6f 64 75 6c |ion} for| a modul|
|00004890| 65 20 6e 61 6d 65 64 20 | 5c 76 61 72 7b 66 6f 6f |e named |\var{foo|
|000048a0| 7d 0d 73 6f 6d 65 77 68 | 65 72 65 2e 29 0d 0d 41 |}.somewh|ere.)..A|
|000048b0| 20 73 70 65 63 69 61 6c | 20 6d 65 6d 62 65 72 20 | special| member |
|000048c0| 6f 66 20 65 76 65 72 79 | 20 6d 6f 64 75 6c 65 20 |of every| module |
|000048d0| 69 73 20 5c 63 6f 64 65 | 7b 5f 5f 64 69 63 74 5f |is \code|{__dict_|
|000048e0| 5f 7d 2e 0d 54 68 69 73 | 20 69 73 20 74 68 65 20 |_}..This| is the |
|000048f0| 64 69 63 74 69 6f 6e 61 | 72 79 20 63 6f 6e 74 61 |dictiona|ry conta|
|00004900| 69 6e 69 6e 67 20 74 68 | 65 20 6d 6f 64 75 6c 65 |ining th|e module|
|00004910| 27 73 20 73 79 6d 62 6f | 6c 20 74 61 62 6c 65 2e |'s symbo|l table.|
|00004920| 0d 4d 6f 64 69 66 79 69 | 6e 67 20 74 68 69 73 20 |.Modifyi|ng this |
|00004930| 64 69 63 74 69 6f 6e 61 | 72 79 20 77 69 6c 6c 20 |dictiona|ry will |
|00004940| 61 63 74 75 61 6c 6c 79 | 20 63 68 61 6e 67 65 20 |actually| change |
|00004950| 74 68 65 20 6d 6f 64 75 | 6c 65 27 73 20 73 79 6d |the modu|le's sym|
|00004960| 62 6f 6c 0d 74 61 62 6c | 65 2c 20 62 75 74 20 64 |bol.tabl|e, but d|
|00004970| 69 72 65 63 74 20 61 73 | 73 69 67 6e 6d 65 6e 74 |irect as|signment|
|00004980| 20 74 6f 20 74 68 65 20 | 5c 63 6f 64 65 7b 5f 5f | to the |\code{__|
|00004990| 64 69 63 74 5f 5f 7d 20 | 61 74 74 72 69 62 75 74 |dict__} |attribut|
|000049a0| 65 20 69 73 20 6e 6f 74 | 0d 70 6f 73 73 69 62 6c |e is not|.possibl|
|000049b0| 65 20 28 69 2e 65 2e 2c | 20 79 6f 75 20 63 61 6e |e (i.e.,| you can|
|000049c0| 20 77 72 69 74 65 20 5c | 63 6f 64 65 7b 5c 76 61 | write \|code{\va|
|000049d0| 72 7b 6d 7d 2e 5f 5f 64 | 69 63 74 5f 5f 5b 27 61 |r{m}.__d|ict__['a|
|000049e0| 27 5d 20 3d 20 31 7d 2c | 20 77 68 69 63 68 0d 64 |'] = 1},| which.d|
|000049f0| 65 66 69 6e 65 73 20 5c | 63 6f 64 65 7b 5c 76 61 |efines \|code{\va|
|00004a00| 72 7b 6d 7d 2e 61 7d 20 | 74 6f 20 62 65 20 5c 63 |r{m}.a} |to be \c|
|00004a10| 6f 64 65 7b 31 7d 2c 20 | 62 75 74 20 79 6f 75 20 |ode{1}, |but you |
|00004a20| 63 61 6e 27 74 20 77 72 | 69 74 65 20 5c 63 6f 64 |can't wr|ite \cod|
|00004a30| 65 7b 5c 76 61 72 7b 6d | 7d 2e 5f 5f 64 69 63 74 |e{\var{m|}.__dict|
|00004a40| 5f 5f 20 3d 20 5c 7b 5c | 7d 7d 2e 0d 0d 4d 6f 64 |__ = \{\|}}...Mod|
|00004a50| 75 6c 65 73 20 61 72 65 | 20 77 72 69 74 74 65 6e |ules are| written|
|00004a60| 20 6c 69 6b 65 20 74 68 | 69 73 3a 20 5c 63 6f 64 | like th|is: \cod|
|00004a70| 65 7b 3c 6d 6f 64 75 6c | 65 20 27 73 79 73 27 3e |e{<modul|e 'sys'>|
|00004a80| 7d 2e 0d 0d 5c 73 75 62 | 73 75 62 73 65 63 74 69 |}...\sub|subsecti|
|00004a90| 6f 6e 7b 43 6c 61 73 73 | 65 73 20 61 6e 64 20 43 |on{Class|es and C|
|00004aa0| 6c 61 73 73 20 49 6e 73 | 74 61 6e 63 65 73 2e 7d |lass Ins|tances.}|
|00004ab0| 0d 25 20 58 58 58 4a 48 | 20 63 72 6f 73 73 20 72 |.% XXXJH| cross r|
|00004ac0| 65 66 20 68 65 72 65 0d | 28 53 65 65 20 74 68 65 |ef here.|(See the|
|00004ad0| 20 50 79 74 68 6f 6e 20 | 52 65 66 65 72 65 6e 63 | Python |Referenc|
|00004ae0| 65 20 4d 61 6e 75 61 6c | 20 66 6f 72 20 74 68 65 |e Manual| for the|
|00004af0| 73 65 2e 29 0d 0d 5c 73 | 75 62 73 75 62 73 65 63 |se.)..\s|ubsubsec|
|00004b00| 74 69 6f 6e 7b 46 75 6e | 63 74 69 6f 6e 73 2e 7d |tion{Fun|ctions.}|
|00004b10| 0d 0d 46 75 6e 63 74 69 | 6f 6e 20 6f 62 6a 65 63 |..Functi|on objec|
|00004b20| 74 73 20 61 72 65 20 63 | 72 65 61 74 65 64 20 62 |ts are c|reated b|
|00004b30| 79 20 66 75 6e 63 74 69 | 6f 6e 20 64 65 66 69 6e |y functi|on defin|
|00004b40| 69 74 69 6f 6e 73 2e 20 | 20 54 68 65 20 6f 6e 6c |itions. | The onl|
|00004b50| 79 0d 6f 70 65 72 61 74 | 69 6f 6e 20 6f 6e 20 61 |y.operat|ion on a|
|00004b60| 20 66 75 6e 63 74 69 6f | 6e 20 6f 62 6a 65 63 74 | functio|n object|
|00004b70| 20 69 73 20 74 6f 20 63 | 61 6c 6c 20 69 74 3a 0d | is to c|all it:.|
|00004b80| 5c 63 6f 64 65 7b 5c 76 | 61 72 7b 66 75 6e 63 7d |\code{\v|ar{func}|
|00004b90| 28 5c 76 61 72 7b 61 72 | 67 75 6d 65 6e 74 2d 6c |(\var{ar|gument-l|
|00004ba0| 69 73 74 7d 29 7d 2e 0d | 0d 54 68 65 72 65 20 61 |ist})}..|.There a|
|00004bb0| 72 65 20 72 65 61 6c 6c | 79 20 74 77 6f 20 66 6c |re reall|y two fl|
|00004bc0| 61 76 6f 72 73 20 6f 66 | 20 66 75 6e 63 74 69 6f |avors of| functio|
|00004bd0| 6e 20 6f 62 6a 65 63 74 | 73 3a 20 62 75 69 6c 74 |n object|s: built|
|00004be0| 2d 69 6e 20 66 75 6e 63 | 74 69 6f 6e 73 0d 61 6e |-in func|tions.an|
|00004bf0| 64 20 75 73 65 72 2d 64 | 65 66 69 6e 65 64 20 66 |d user-d|efined f|
|00004c00| 75 6e 63 74 69 6f 6e 73 | 2e 20 20 42 6f 74 68 20 |unctions|. Both |
|00004c10| 73 75 70 70 6f 72 74 20 | 74 68 65 20 73 61 6d 65 |support |the same|
|00004c20| 20 6f 70 65 72 61 74 69 | 6f 6e 20 28 74 6f 20 63 | operati|on (to c|
|00004c30| 61 6c 6c 0d 74 68 65 20 | 66 75 6e 63 74 69 6f 6e |all.the |function|
|00004c40| 29 2c 20 62 75 74 20 74 | 68 65 20 69 6d 70 6c 65 |), but t|he imple|
|00004c50| 6d 65 6e 74 61 74 69 6f | 6e 20 69 73 20 64 69 66 |mentatio|n is dif|
|00004c60| 66 65 72 65 6e 74 2c 20 | 68 65 6e 63 65 20 74 68 |ferent, |hence th|
|00004c70| 65 0d 64 69 66 66 65 72 | 65 6e 74 20 6f 62 6a 65 |e.differ|ent obje|
|00004c80| 63 74 20 74 79 70 65 73 | 2e 0d 0d 54 68 65 20 69 |ct types|...The i|
|00004c90| 6d 70 6c 65 6d 65 6e 74 | 61 74 69 6f 6e 20 61 64 |mplement|ation ad|
|00004ca0| 64 73 20 74 77 6f 20 73 | 70 65 63 69 61 6c 20 72 |ds two s|pecial r|
|00004cb0| 65 61 64 2d 6f 6e 6c 79 | 20 61 74 74 72 69 62 75 |ead-only| attribu|
|00004cc0| 74 65 73 3a 0d 5c 63 6f | 64 65 7b 5c 76 61 72 7b |tes:.\co|de{\var{|
|00004cd0| 66 7d 2e 66 75 6e 63 5f | 63 6f 64 65 7d 20 69 73 |f}.func_|code} is|
|00004ce0| 20 61 20 66 75 6e 63 74 | 69 6f 6e 27 73 20 5c 64 | a funct|ion's \d|
|00004cf0| 66 6e 7b 63 6f 64 65 20 | 6f 62 6a 65 63 74 7d 20 |fn{code |object} |
|00004d00| 28 73 65 65 20 62 65 6c | 6f 77 29 20 61 6e 64 0d |(see bel|ow) and.|
|00004d10| 5c 63 6f 64 65 7b 5c 76 | 61 72 7b 66 7d 2e 66 75 |\code{\v|ar{f}.fu|
|00004d20| 6e 63 5f 67 6c 6f 62 61 | 6c 73 7d 20 69 73 20 74 |nc_globa|ls} is t|
|00004d30| 68 65 20 64 69 63 74 69 | 6f 6e 61 72 79 20 75 73 |he dicti|onary us|
|00004d40| 65 64 20 61 73 20 74 68 | 65 20 66 75 6e 63 74 69 |ed as th|e functi|
|00004d50| 6f 6e 27 73 0d 67 6c 6f | 62 61 6c 20 6e 61 6d 65 |on's.glo|bal name|
|00004d60| 20 73 70 61 63 65 20 28 | 74 68 69 73 20 69 73 20 | space (|this is |
|00004d70| 74 68 65 20 73 61 6d 65 | 20 61 73 20 5c 63 6f 64 |the same| as \cod|
|00004d80| 65 7b 5c 76 61 72 7b 6d | 7d 2e 5f 5f 64 69 63 74 |e{\var{m|}.__dict|
|00004d90| 5f 5f 7d 20 77 68 65 72 | 65 0d 5c 76 61 72 7b 6d |__} wher|e.\var{m|
|00004da0| 7d 20 69 73 20 74 68 65 | 20 6d 6f 64 75 6c 65 20 |} is the| module |
|00004db0| 69 6e 20 77 68 69 63 68 | 20 74 68 65 20 66 75 6e |in which| the fun|
|00004dc0| 63 74 69 6f 6e 20 5c 76 | 61 72 7b 66 7d 20 77 61 |ction \v|ar{f} wa|
|00004dd0| 73 20 64 65 66 69 6e 65 | 64 29 2e 0d 0d 5c 73 75 |s define|d)...\su|
|00004de0| 62 73 75 62 73 65 63 74 | 69 6f 6e 7b 4d 65 74 68 |bsubsect|ion{Meth|
|00004df0| 6f 64 73 2e 7d 0d 0d 4d | 65 74 68 6f 64 73 20 61 |ods.}..M|ethods a|
|00004e00| 72 65 20 66 75 6e 63 74 | 69 6f 6e 73 20 74 68 61 |re funct|ions tha|
|00004e10| 74 20 61 72 65 20 63 61 | 6c 6c 65 64 20 75 73 69 |t are ca|lled usi|
|00004e20| 6e 67 20 74 68 65 20 61 | 74 74 72 69 62 75 74 65 |ng the a|ttribute|
|00004e30| 20 6e 6f 74 61 74 69 6f | 6e 2e 0d 54 68 65 72 65 | notatio|n..There|
|00004e40| 20 61 72 65 20 74 77 6f | 20 66 6c 61 76 6f 72 73 | are two| flavors|
|00004e50| 3a 20 62 75 69 6c 74 2d | 69 6e 20 6d 65 74 68 6f |: built-|in metho|
|00004e60| 64 73 20 28 73 75 63 68 | 20 61 73 20 5c 63 6f 64 |ds (such| as \cod|
|00004e70| 65 7b 61 70 70 65 6e 64 | 28 29 7d 20 6f 6e 0d 6c |e{append|()} on.l|
|00004e80| 69 73 74 73 29 20 61 6e | 64 20 63 6c 61 73 73 20 |ists) an|d class |
|00004e90| 69 6e 73 74 61 6e 63 65 | 20 6d 65 74 68 6f 64 73 |instance| methods|
|00004ea0| 2e 20 20 42 75 69 6c 74 | 2d 69 6e 20 6d 65 74 68 |. Built|-in meth|
|00004eb0| 6f 64 73 20 61 72 65 20 | 64 65 73 63 72 69 62 65 |ods are |describe|
|00004ec0| 64 0d 77 69 74 68 20 74 | 68 65 20 74 79 70 65 73 |d.with t|he types|
|00004ed0| 20 74 68 61 74 20 73 75 | 70 70 6f 72 74 20 74 68 | that su|pport th|
|00004ee0| 65 6d 2e 0d 0d 54 68 65 | 20 69 6d 70 6c 65 6d 65 |em...The| impleme|
|00004ef0| 6e 74 61 74 69 6f 6e 20 | 61 64 64 73 20 74 77 6f |ntation |adds two|
|00004f00| 20 73 70 65 63 69 61 6c | 20 72 65 61 64 2d 6f 6e | special| read-on|
|00004f10| 6c 79 20 61 74 74 72 69 | 62 75 74 65 73 20 74 6f |ly attri|butes to|
|00004f20| 20 63 6c 61 73 73 0d 69 | 6e 73 74 61 6e 63 65 20 | class.i|nstance |
|00004f30| 6d 65 74 68 6f 64 73 3a | 20 5c 63 6f 64 65 7b 5c |methods:| \code{\|
|00004f40| 76 61 72 7b 6d 7d 2e 69 | 6d 5f 73 65 6c 66 7d 20 |var{m}.i|m_self} |
|00004f50| 69 73 20 74 68 65 20 6f | 62 6a 65 63 74 20 77 68 |is the o|bject wh|
|00004f60| 6f 73 65 20 6d 65 74 68 | 6f 64 20 74 68 69 73 0d |ose meth|od this.|
|00004f70| 69 73 2c 20 61 6e 64 20 | 5c 63 6f 64 65 7b 5c 76 |is, and |\code{\v|
|00004f80| 61 72 7b 6d 7d 2e 69 6d | 5f 66 75 6e 63 7d 20 69 |ar{m}.im|_func} i|
|00004f90| 73 20 74 68 65 20 66 75 | 6e 63 74 69 6f 6e 20 69 |s the fu|nction i|
|00004fa0| 6d 70 6c 65 6d 65 6e 74 | 69 6e 67 20 74 68 65 20 |mplement|ing the |
|00004fb0| 6d 65 74 68 6f 64 2e 0d | 43 61 6c 6c 69 6e 67 20 |method..|Calling |
|00004fc0| 5c 63 6f 64 65 7b 5c 76 | 61 72 7b 6d 7d 28 5c 76 |\code{\v|ar{m}(\v|
|00004fd0| 61 72 7b 61 72 67 2d 31 | 7d 2c 20 5c 76 61 72 7b |ar{arg-1|}, \var{|
|00004fe0| 61 72 67 2d 32 7d 2c 20 | 7b 5c 72 6d 20 5c 6c 64 |arg-2}, |{\rm \ld|
|00004ff0| 6f 74 73 7d 2c 0d 5c 76 | 61 72 7b 61 72 67 2d 6e |ots},.\v|ar{arg-n|
|00005000| 7d 29 7d 20 69 73 20 63 | 6f 6d 70 6c 65 74 65 6c |})} is c|ompletel|
|00005010| 79 20 65 71 75 69 76 61 | 6c 65 6e 74 20 74 6f 20 |y equiva|lent to |
|00005020| 63 61 6c 6c 69 6e 67 0d | 5c 63 6f 64 65 7b 5c 76 |calling.|\code{\v|
|00005030| 61 72 7b 6d 7d 2e 69 6d | 5f 66 75 6e 63 28 5c 76 |ar{m}.im|_func(\v|
|00005040| 61 72 7b 6d 7d 2e 69 6d | 5f 73 65 6c 66 2c 20 5c |ar{m}.im|_self, \|
|00005050| 76 61 72 7b 61 72 67 2d | 31 7d 2c 20 5c 76 61 72 |var{arg-|1}, \var|
|00005060| 7b 61 72 67 2d 32 7d 2c | 20 7b 5c 72 6d 0d 5c 6c |{arg-2},| {\rm.\l|
|00005070| 64 6f 74 73 7d 2c 20 5c | 76 61 72 7b 61 72 67 2d |dots}, \|var{arg-|
|00005080| 6e 7d 29 7d 2e 0d 0d 28 | 53 65 65 20 74 68 65 20 |n})}...(|See the |
|00005090| 50 79 74 68 6f 6e 20 52 | 65 66 65 72 65 6e 63 65 |Python R|eference|
|000050a0| 20 4d 61 6e 75 61 6c 20 | 66 6f 72 20 6d 6f 72 65 | Manual |for more|
|000050b0| 20 69 6e 66 6f 2e 29 0d | 0d 5c 73 75 62 73 75 62 | info.).|.\subsub|
|000050c0| 73 65 63 74 69 6f 6e 7b | 54 79 70 65 20 4f 62 6a |section{|Type Obj|
|000050d0| 65 63 74 73 2e 7d 0d 0d | 54 79 70 65 20 6f 62 6a |ects.}..|Type obj|
|000050e0| 65 63 74 73 20 72 65 70 | 72 65 73 65 6e 74 20 74 |ects rep|resent t|
|000050f0| 68 65 20 76 61 72 69 6f | 75 73 20 6f 62 6a 65 63 |he vario|us objec|
|00005100| 74 20 74 79 70 65 73 2e | 20 20 41 6e 20 6f 62 6a |t types.| An obj|
|00005110| 65 63 74 27 73 20 74 79 | 70 65 20 69 73 0d 25 20 |ect's ty|pe is.% |
|00005120| 58 58 58 4a 48 20 78 72 | 65 66 20 68 65 72 65 0d |XXXJH xr|ef here.|
|00005130| 61 63 63 65 73 73 65 64 | 20 62 79 20 74 68 65 20 |accessed| by the |
|00005140| 62 75 69 6c 74 2d 69 6e | 20 66 75 6e 63 74 69 6f |built-in| functio|
|00005150| 6e 20 5c 63 6f 64 65 7b | 74 79 70 65 28 29 7d 2e |n \code{|type()}.|
|00005160| 20 20 54 68 65 72 65 20 | 61 72 65 20 6e 6f 20 73 | There |are no s|
|00005170| 70 65 63 69 61 6c 0d 6f | 70 65 72 61 74 69 6f 6e |pecial.o|peration|
|00005180| 73 20 6f 6e 20 74 79 70 | 65 73 2e 0d 0d 54 79 70 |s on typ|es...Typ|
|00005190| 65 73 20 61 72 65 20 77 | 72 69 74 74 65 6e 20 6c |es are w|ritten l|
|000051a0| 69 6b 65 20 74 68 69 73 | 3a 20 5c 63 6f 64 65 7b |ike this|: \code{|
|000051b0| 3c 74 79 70 65 20 27 69 | 6e 74 27 3e 7d 2e 0d 0d |<type 'i|nt'>}...|
|000051c0| 5c 73 75 62 73 75 62 73 | 65 63 74 69 6f 6e 7b 54 |\subsubs|ection{T|
|000051d0| 68 65 20 4e 75 6c 6c 20 | 4f 62 6a 65 63 74 2e 7d |he Null |Object.}|
|000051e0| 0d 0d 54 68 69 73 20 6f | 62 6a 65 63 74 20 69 73 |..This o|bject is|
|000051f0| 20 72 65 74 75 72 6e 65 | 64 20 62 79 20 66 75 6e | returne|d by fun|
|00005200| 63 74 69 6f 6e 73 20 74 | 68 61 74 20 64 6f 6e 27 |ctions t|hat don'|
|00005210| 74 20 65 78 70 6c 69 63 | 69 74 6c 79 20 72 65 74 |t explic|itly ret|
|00005220| 75 72 6e 20 61 0d 76 61 | 6c 75 65 2e 20 20 49 74 |urn a.va|lue. It|
|00005230| 20 73 75 70 70 6f 72 74 | 73 20 6e 6f 20 73 70 65 | support|s no spe|
|00005240| 63 69 61 6c 20 6f 70 65 | 72 61 74 69 6f 6e 73 2e |cial ope|rations.|
|00005250| 20 20 54 68 65 72 65 20 | 69 73 20 65 78 61 63 74 | There |is exact|
|00005260| 6c 79 20 6f 6e 65 20 6e | 75 6c 6c 0d 6f 62 6a 65 |ly one n|ull.obje|
|00005270| 63 74 2c 20 6e 61 6d 65 | 64 20 5c 63 6f 64 65 7b |ct, name|d \code{|
|00005280| 4e 6f 6e 65 7d 20 28 61 | 20 62 75 69 6c 74 2d 69 |None} (a| built-i|
|00005290| 6e 20 6e 61 6d 65 29 2e | 0d 0d 49 74 20 69 73 20 |n name).|..It is |
|000052a0| 77 72 69 74 74 65 6e 20 | 61 73 20 5c 63 6f 64 65 |written |as \code|
|000052b0| 7b 4e 6f 6e 65 7d 2e 0d | 0d 5c 73 75 62 73 75 62 |{None}..|.\subsub|
|000052c0| 73 65 63 74 69 6f 6e 7b | 46 69 6c 65 20 4f 62 6a |section{|File Obj|
|000052d0| 65 63 74 73 2e 7d 0d 0d | 46 69 6c 65 20 6f 62 6a |ects.}..|File obj|
|000052e0| 65 63 74 73 20 61 72 65 | 20 69 6d 70 6c 65 6d 65 |ects are| impleme|
|000052f0| 6e 74 65 64 20 75 73 69 | 6e 67 20 5c 43 7b 7d 27 |nted usi|ng \C{}'|
|00005300| 73 20 5c 63 6f 64 65 7b | 73 74 64 69 6f 7d 20 70 |s \code{|stdio} p|
|00005310| 61 63 6b 61 67 65 20 61 | 6e 64 20 63 61 6e 20 62 |ackage a|nd can b|
|00005320| 65 0d 25 20 58 58 58 4a | 48 20 78 72 65 66 20 68 |e.% XXXJ|H xref h|
|00005330| 65 72 65 0d 63 72 65 61 | 74 65 64 20 77 69 74 68 |ere.crea|ted with|
|00005340| 20 74 68 65 20 62 75 69 | 6c 74 2d 69 6e 20 66 75 | the bui|lt-in fu|
|00005350| 6e 63 74 69 6f 6e 20 5c | 63 6f 64 65 7b 6f 70 65 |nction \|code{ope|
|00005360| 6e 28 29 7d 20 64 65 73 | 63 72 69 62 65 64 20 75 |n()} des|cribed u|
|00005370| 6e 64 65 72 0d 42 75 69 | 6c 74 2d 69 6e 20 46 75 |nder.Bui|lt-in Fu|
|00005380| 6e 63 74 69 6f 6e 73 20 | 62 65 6c 6f 77 2e 0d 0d |nctions |below...|
|00005390| 57 68 65 6e 20 61 20 66 | 69 6c 65 20 6f 70 65 72 |When a f|ile oper|
|000053a0| 61 74 69 6f 6e 20 66 61 | 69 6c 73 20 66 6f 72 20 |ation fa|ils for |
|000053b0| 61 6e 20 49 2f 4f 2d 72 | 65 6c 61 74 65 64 20 72 |an I/O-r|elated r|
|000053c0| 65 61 73 6f 6e 2c 20 74 | 68 65 20 65 78 63 65 70 |eason, t|he excep|
|000053d0| 74 69 6f 6e 0d 5c 63 6f | 64 65 7b 49 4f 45 72 72 |tion.\co|de{IOErr|
|000053e0| 6f 72 7d 20 69 73 20 72 | 61 69 73 65 64 2e 20 20 |or} is r|aised. |
|000053f0| 54 68 69 73 20 69 6e 63 | 6c 75 64 65 73 20 73 69 |This inc|ludes si|
|00005400| 74 75 61 74 69 6f 6e 73 | 20 77 68 65 72 65 20 74 |tuations| where t|
|00005410| 68 65 0d 6f 70 65 72 61 | 74 69 6f 6e 20 69 73 20 |he.opera|tion is |
|00005420| 6e 6f 74 20 64 65 66 69 | 6e 65 64 20 66 6f 72 20 |not defi|ned for |
|00005430| 73 6f 6d 65 20 72 65 61 | 73 6f 6e 2c 20 6c 69 6b |some rea|son, lik|
|00005440| 65 20 5c 63 6f 64 65 7b | 73 65 65 6b 28 29 7d 20 |e \code{|seek()} |
|00005450| 6f 6e 20 61 20 74 74 79 | 0d 64 65 76 69 63 65 20 |on a tty|.device |
|00005460| 6f 72 20 77 72 69 74 69 | 6e 67 20 61 20 66 69 6c |or writi|ng a fil|
|00005470| 65 20 6f 70 65 6e 65 64 | 20 66 6f 72 20 72 65 61 |e opened| for rea|
|00005480| 64 69 6e 67 2e 0d 0d 46 | 69 6c 65 73 20 68 61 76 |ding...F|iles hav|
|00005490| 65 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |e the fo|llowing |
|000054a0| 6d 65 74 68 6f 64 73 3a | 0d 0d 0d 5c 72 65 6e 65 |methods:|...\rene|
|000054b0| 77 63 6f 6d 6d 61 6e 64 | 7b 5c 69 6e 64 65 78 73 |wcommand|{\indexs|
|000054c0| 75 62 69 74 65 6d 7d 7b | 28 66 69 6c 65 20 6d 65 |ubitem}{|(file me|
|000054d0| 74 68 6f 64 29 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |thod)}..|\begin{f|
|000054e0| 75 6e 63 64 65 73 63 7d | 7b 63 6c 6f 73 65 7d 7b |uncdesc}|{close}{|
|000054f0| 7d 0d 20 20 43 6c 6f 73 | 65 20 74 68 65 20 66 69 |}. Clos|e the fi|
|00005500| 6c 65 2e 20 20 41 20 63 | 6c 6f 73 65 64 20 66 69 |le. A c|losed fi|
|00005510| 6c 65 20 63 61 6e 6e 6f | 74 20 62 65 20 72 65 61 |le canno|t be rea|
|00005520| 64 20 6f 72 20 77 72 69 | 74 74 65 6e 20 61 6e 79 |d or wri|tten any|
|00005530| 6d 6f 72 65 2e 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |more..\e|nd{funcd|
|00005540| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00005550| 63 64 65 73 63 7d 7b 66 | 6c 75 73 68 7d 7b 7d 0d |cdesc}{f|lush}{}.|
|00005560| 20 20 46 6c 75 73 68 20 | 74 68 65 20 69 6e 74 65 | Flush |the inte|
|00005570| 72 6e 61 6c 20 62 75 66 | 66 65 72 2c 20 6c 69 6b |rnal buf|fer, lik|
|00005580| 65 20 5c 63 6f 64 65 7b | 73 74 64 69 6f 7d 27 73 |e \code{|stdio}'s|
|00005590| 20 5c 63 6f 64 65 7b 66 | 66 6c 75 73 68 28 29 7d | \code{f|flush()}|
|000055a0| 2e 0d 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|000055b0| 0d 0d 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|000055c0| 63 7d 7b 69 73 61 74 74 | 79 7d 7b 7d 0d 20 20 52 |c}{isatt|y}{}. R|
|000055d0| 65 74 75 72 6e 20 5c 63 | 6f 64 65 7b 31 7d 20 69 |eturn \c|ode{1} i|
|000055e0| 66 20 74 68 65 20 66 69 | 6c 65 20 69 73 20 63 6f |f the fi|le is co|
|000055f0| 6e 6e 65 63 74 65 64 20 | 74 6f 20 61 20 74 74 79 |nnected |to a tty|
|00005600| 28 2d 6c 69 6b 65 29 20 | 64 65 76 69 63 65 2c 20 |(-like) |device, |
|00005610| 65 6c 73 65 0d 20 20 5c | 63 6f 64 65 7b 30 7d 2e |else. \|code{0}.|
|00005620| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00005630| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00005640| 7d 7b 72 65 61 64 7d 7b | 73 69 7a 65 7d 0d 20 20 |}{read}{|size}. |
|00005650| 52 65 61 64 20 61 74 20 | 6d 6f 73 74 20 5c 76 61 |Read at |most \va|
|00005660| 72 7b 73 69 7a 65 7d 20 | 62 79 74 65 73 20 66 72 |r{size} |bytes fr|
|00005670| 6f 6d 20 74 68 65 20 66 | 69 6c 65 20 28 6c 65 73 |om the f|ile (les|
|00005680| 73 20 69 66 20 74 68 65 | 20 72 65 61 64 20 68 69 |s if the| read hi|
|00005690| 74 73 0d 20 20 5c 45 4f | 46 7b 7d 20 6f 72 20 6e |ts. \EO|F{} or n|
|000056a0| 6f 20 6d 6f 72 65 20 64 | 61 74 61 20 69 73 20 69 |o more d|ata is i|
|000056b0| 6d 6d 65 64 69 61 74 65 | 6c 79 20 61 76 61 69 6c |mmediate|ly avail|
|000056c0| 61 62 6c 65 20 6f 6e 20 | 61 20 70 69 70 65 2c 20 |able on |a pipe, |
|000056d0| 74 74 79 20 6f 72 0d 20 | 20 73 69 6d 69 6c 61 72 |tty or. | similar|
|000056e0| 20 64 65 76 69 63 65 29 | 2e 20 20 49 66 20 74 68 | device)|. If th|
|000056f0| 65 20 5c 76 61 72 7b 73 | 69 7a 65 7d 20 61 72 67 |e \var{s|ize} arg|
|00005700| 75 6d 65 6e 74 20 69 73 | 20 6f 6d 69 74 74 65 64 |ument is| omitted|
|00005710| 2c 20 72 65 61 64 20 61 | 6c 6c 0d 20 20 64 61 74 |, read a|ll. dat|
|00005720| 61 20 75 6e 74 69 6c 20 | 5c 45 4f 46 7b 7d 20 69 |a until |\EOF{} i|
|00005730| 73 20 72 65 61 63 68 65 | 64 2e 20 20 54 68 65 20 |s reache|d. The |
|00005740| 62 79 74 65 73 20 61 72 | 65 20 72 65 74 75 72 6e |bytes ar|e return|
|00005750| 65 64 20 61 73 20 61 20 | 73 74 72 69 6e 67 0d 20 |ed as a |string. |
|00005760| 20 6f 62 6a 65 63 74 2e | 20 20 41 6e 20 65 6d 70 | object.| An emp|
|00005770| 74 79 20 73 74 72 69 6e | 67 20 69 73 20 72 65 74 |ty strin|g is ret|
|00005780| 75 72 6e 65 64 20 77 68 | 65 6e 20 5c 45 4f 46 7b |urned wh|en \EOF{|
|00005790| 7d 20 69 73 20 65 6e 63 | 6f 75 6e 74 65 72 65 64 |} is enc|ountered|
|000057a0| 0d 20 20 69 6d 6d 65 64 | 69 61 74 65 6c 79 2e 20 |. immed|iately. |
|000057b0| 20 28 46 6f 72 20 63 65 | 72 74 61 69 6e 20 66 69 | (For ce|rtain fi|
|000057c0| 6c 65 73 2c 20 6c 69 6b | 65 20 74 74 79 73 2c 20 |les, lik|e ttys, |
|000057d0| 69 74 20 6d 61 6b 65 73 | 20 73 65 6e 73 65 20 74 |it makes| sense t|
|000057e0| 6f 0d 20 20 63 6f 6e 74 | 69 6e 75 65 20 72 65 61 |o. cont|inue rea|
|000057f0| 64 69 6e 67 20 61 66 74 | 65 72 20 61 6e 20 5c 45 |ding aft|er an \E|
|00005800| 4f 46 7b 7d 20 69 73 20 | 68 69 74 2e 29 0d 5c 65 |OF{} is |hit.).\e|
|00005810| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0d 0d 5c 62 |nd{funcd|esc}..\b|
|00005820| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 72 |egin{fun|cdesc}{r|
|00005830| 65 61 64 6c 69 6e 65 7d | 7b 7d 0d 20 20 52 65 61 |eadline}|{}. Rea|
|00005840| 64 20 6f 6e 65 20 65 6e | 74 69 72 65 20 6c 69 6e |d one en|tire lin|
|00005850| 65 20 66 72 6f 6d 20 74 | 68 65 20 66 69 6c 65 2e |e from t|he file.|
|00005860| 20 20 41 20 74 72 61 69 | 6c 69 6e 67 20 6e 65 77 | A trai|ling new|
|00005870| 6c 69 6e 65 20 63 68 61 | 72 61 63 74 65 72 20 69 |line cha|racter i|
|00005880| 73 0d 20 20 6b 65 70 74 | 20 69 6e 20 74 68 65 20 |s. kept| in the |
|00005890| 73 74 72 69 6e 67 20 28 | 62 75 74 20 6d 61 79 20 |string (|but may |
|000058a0| 62 65 20 61 62 73 65 6e | 74 20 77 68 65 6e 20 61 |be absen|t when a|
|000058b0| 20 66 69 6c 65 20 65 6e | 64 73 20 77 69 74 68 20 | file en|ds with |
|000058c0| 61 6e 0d 20 20 69 6e 63 | 6f 6d 70 6c 65 74 65 20 |an. inc|omplete |
|000058d0| 6c 69 6e 65 29 2e 20 20 | 41 6e 20 65 6d 70 74 79 |line). |An empty|
|000058e0| 20 73 74 72 69 6e 67 20 | 69 73 20 72 65 74 75 72 | string |is retur|
|000058f0| 6e 65 64 20 77 68 65 6e | 20 5c 45 4f 46 7b 7d 20 |ned when| \EOF{} |
|00005900| 69 73 20 68 69 74 0d 20 | 20 69 6d 6d 65 64 69 61 |is hit. | immedia|
|00005910| 74 65 6c 79 2e 20 20 4e | 6f 74 65 3a 20 75 6e 6c |tely. N|ote: unl|
|00005920| 69 6b 65 20 5c 63 6f 64 | 65 7b 73 74 64 69 6f 7d |ike \cod|e{stdio}|
|00005930| 27 73 20 5c 63 6f 64 65 | 7b 66 67 65 74 73 28 29 |'s \code|{fgets()|
|00005940| 7d 2c 20 74 68 65 20 72 | 65 74 75 72 6e 65 64 0d |}, the r|eturned.|
|00005950| 20 20 73 74 72 69 6e 67 | 20 63 6f 6e 74 61 69 6e | string| contain|
|00005960| 73 20 6e 75 6c 6c 20 63 | 68 61 72 61 63 74 65 72 |s null c|haracter|
|00005970| 73 20 28 5c 63 6f 64 65 | 7b 27 5c 65 20 30 27 7d |s (\code|{'\e 0'}|
|00005980| 29 20 69 66 20 74 68 65 | 79 20 6f 63 63 75 72 72 |) if the|y occurr|
|00005990| 65 64 20 69 6e 20 74 68 | 65 0d 20 20 69 6e 70 75 |ed in th|e. inpu|
|000059a0| 74 2e 0d 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |t..\end{|funcdesc|
|000059b0| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|000059c0| 73 63 7d 7b 72 65 61 64 | 6c 69 6e 65 73 7d 7b 7d |sc}{read|lines}{}|
|000059d0| 0d 20 20 52 65 61 64 20 | 75 6e 74 69 6c 20 5c 45 |. Read |until \E|
|000059e0| 4f 46 7b 7d 20 75 73 69 | 6e 67 20 5c 63 6f 64 65 |OF{} usi|ng \code|
|000059f0| 7b 72 65 61 64 6c 69 6e | 65 28 29 7d 20 61 6e 64 |{readlin|e()} and|
|00005a00| 20 72 65 74 75 72 6e 20 | 61 20 6c 69 73 74 20 63 | return |a list c|
|00005a10| 6f 6e 74 61 69 6e 69 6e | 67 0d 20 20 74 68 65 20 |ontainin|g. the |
|00005a20| 6c 69 6e 65 73 20 74 68 | 75 73 20 72 65 61 64 2e |lines th|us read.|
|00005a30| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00005a40| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00005a50| 7d 7b 73 65 65 6b 7d 7b | 6f 66 66 73 65 74 5c 2c |}{seek}{|offset\,|
|00005a60| 20 77 68 65 6e 63 65 7d | 0d 20 20 53 65 74 20 74 | whence}|. Set t|
|00005a70| 68 65 20 66 69 6c 65 27 | 73 20 63 75 72 72 65 6e |he file'|s curren|
|00005a80| 74 20 70 6f 73 69 74 69 | 6f 6e 2c 20 6c 69 6b 65 |t positi|on, like|
|00005a90| 20 5c 63 6f 64 65 7b 73 | 74 64 69 6f 7d 27 73 20 | \code{s|tdio}'s |
|00005aa0| 5c 63 6f 64 65 7b 66 73 | 65 65 6b 28 29 7d 2e 0d |\code{fs|eek()}..|
|00005ab0| 20 20 54 68 65 20 5c 76 | 61 72 7b 77 68 65 6e 63 | The \v|ar{whenc|
|00005ac0| 65 7d 20 61 72 67 75 6d | 65 6e 74 20 69 73 20 6f |e} argum|ent is o|
|00005ad0| 70 74 69 6f 6e 61 6c 20 | 61 6e 64 20 64 65 66 61 |ptional |and defa|
|00005ae0| 75 6c 74 73 20 74 6f 20 | 5c 63 6f 64 65 7b 30 7d |ults to |\code{0}|
|00005af0| 0d 20 20 28 61 62 73 6f | 6c 75 74 65 20 66 69 6c |. (abso|lute fil|
|00005b00| 65 20 70 6f 73 69 74 69 | 6f 6e 69 6e 67 29 3b 20 |e positi|oning); |
|00005b10| 6f 74 68 65 72 20 76 61 | 6c 75 65 73 20 61 72 65 |other va|lues are|
|00005b20| 20 5c 63 6f 64 65 7b 31 | 7d 20 28 73 65 65 6b 0d | \code{1|} (seek.|
|00005b30| 20 20 72 65 6c 61 74 69 | 76 65 20 74 6f 20 74 68 | relati|ve to th|
|00005b40| 65 20 63 75 72 72 65 6e | 74 20 70 6f 73 69 74 69 |e curren|t positi|
|00005b50| 6f 6e 29 20 61 6e 64 20 | 5c 63 6f 64 65 7b 32 7d |on) and |\code{2}|
|00005b60| 20 28 73 65 65 6b 20 72 | 65 6c 61 74 69 76 65 20 | (seek r|elative |
|00005b70| 74 6f 20 74 68 65 0d 20 | 20 66 69 6c 65 27 73 20 |to the. | file's |
|00005b80| 65 6e 64 29 2e 20 20 54 | 68 65 72 65 20 69 73 20 |end). T|here is |
|00005b90| 6e 6f 20 72 65 74 75 72 | 6e 20 76 61 6c 75 65 2e |no retur|n value.|
|00005ba0| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00005bb0| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00005bc0| 7d 7b 74 65 6c 6c 7d 7b | 7d 0d 20 20 52 65 74 75 |}{tell}{|}. Retu|
|00005bd0| 72 6e 20 74 68 65 20 66 | 69 6c 65 27 73 20 63 75 |rn the f|ile's cu|
|00005be0| 72 72 65 6e 74 20 70 6f | 73 69 74 69 6f 6e 2c 20 |rrent po|sition, |
|00005bf0| 6c 69 6b 65 20 5c 63 6f | 64 65 7b 73 74 64 69 6f |like \co|de{stdio|
|00005c00| 7d 27 73 20 5c 63 6f 64 | 65 7b 66 74 65 6c 6c 28 |}'s \cod|e{ftell(|
|00005c10| 29 7d 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |)}..\end|{funcdes|
|00005c20| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|00005c30| 65 73 63 7d 7b 77 72 69 | 74 65 7d 7b 73 74 72 7d |esc}{wri|te}{str}|
|00005c40| 0d 20 20 57 72 69 74 65 | 20 61 20 73 74 72 69 6e |. Write| a strin|
|00005c50| 67 20 74 6f 20 74 68 65 | 20 66 69 6c 65 2e 20 20 |g to the| file. |
|00005c60| 54 68 65 72 65 20 69 73 | 20 6e 6f 20 72 65 74 75 |There is| no retu|
|00005c70| 72 6e 20 76 61 6c 75 65 | 2e 0d 5c 65 6e 64 7b 66 |rn value|..\end{f|
|00005c80| 75 6e 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00005c90| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 77 72 69 74 65 |{funcdes|c}{write|
|00005ca0| 6c 69 6e 65 73 7d 7b 6c | 69 73 74 7d 0d 57 72 69 |lines}{l|ist}.Wri|
|00005cb0| 74 65 20 61 20 6c 69 73 | 74 20 6f 66 20 73 74 72 |te a lis|t of str|
|00005cc0| 69 6e 67 73 20 74 6f 20 | 74 68 65 20 66 69 6c 65 |ings to |the file|
|00005cd0| 2e 20 20 54 68 65 72 65 | 20 69 73 20 6e 6f 20 72 |. There| is no r|
|00005ce0| 65 74 75 72 6e 20 76 61 | 6c 75 65 2e 0d 28 54 68 |eturn va|lue..(Th|
|00005cf0| 65 20 6e 61 6d 65 20 69 | 73 20 69 6e 74 65 6e 64 |e name i|s intend|
|00005d00| 65 64 20 74 6f 20 6d 61 | 74 63 68 20 5c 63 6f 64 |ed to ma|tch \cod|
|00005d10| 65 7b 72 65 61 64 6c 69 | 6e 65 73 7d 3b 20 5c 63 |e{readli|nes}; \c|
|00005d20| 6f 64 65 7b 77 72 69 74 | 65 6c 69 6e 65 73 7d 0d |ode{writ|elines}.|
|00005d30| 64 6f 65 73 20 6e 6f 74 | 20 61 64 64 20 6c 69 6e |does not| add lin|
|00005d40| 65 20 73 65 70 61 72 61 | 74 6f 72 73 2e 29 0d 5c |e separa|tors.).\|
|00005d50| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0d 0d 5c |end{func|desc}..\|
|00005d60| 73 75 62 73 75 62 73 65 | 63 74 69 6f 6e 7b 49 6e |subsubse|ction{In|
|00005d70| 74 65 72 6e 61 6c 20 4f | 62 6a 65 63 74 73 2e 7d |ternal O|bjects.}|
|00005d80| 0d 0d 28 53 65 65 20 74 | 68 65 20 50 79 74 68 6f |..(See t|he Pytho|
|00005d90| 6e 20 52 65 66 65 72 65 | 6e 63 65 20 4d 61 6e 75 |n Refere|nce Manu|
|00005da0| 61 6c 20 66 6f 72 20 74 | 68 65 73 65 2e 29 0d 0d |al for t|hese.)..|
|00005db0| 5c 73 75 62 73 65 63 74 | 69 6f 6e 7b 53 70 65 63 |\subsect|ion{Spec|
|00005dc0| 69 61 6c 20 41 74 74 72 | 69 62 75 74 65 73 7d 0d |ial Attr|ibutes}.|
|00005dd0| 0d 54 68 65 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |.The imp|lementat|
|00005de0| 69 6f 6e 20 61 64 64 73 | 20 61 20 66 65 77 20 73 |ion adds| a few s|
|00005df0| 70 65 63 69 61 6c 20 72 | 65 61 64 2d 6f 6e 6c 79 |pecial r|ead-only|
|00005e00| 20 61 74 74 72 69 62 75 | 74 65 73 20 74 6f 20 73 | attribu|tes to s|
|00005e10| 65 76 65 72 61 6c 0d 6f | 62 6a 65 63 74 20 74 79 |everal.o|bject ty|
|00005e20| 70 65 73 2c 20 77 68 65 | 72 65 20 74 68 65 79 20 |pes, whe|re they |
|00005e30| 61 72 65 20 72 65 6c 65 | 76 61 6e 74 3a 0d 0d 5c |are rele|vant:..\|
|00005e40| 62 65 67 69 6e 7b 69 74 | 65 6d 69 7a 65 7d 0d 0d |begin{it|emize}..|
|00005e50| 5c 69 74 65 6d 0d 5c 63 | 6f 64 65 7b 5c 76 61 72 |\item.\c|ode{\var|
|00005e60| 7b 78 7d 2e 5f 5f 64 69 | 63 74 5f 5f 7d 20 69 73 |{x}.__di|ct__} is|
|00005e70| 20 61 20 64 69 63 74 69 | 6f 6e 61 72 79 20 6f 66 | a dicti|onary of|
|00005e80| 20 73 6f 6d 65 20 73 6f | 72 74 20 75 73 65 64 20 | some so|rt used |
|00005e90| 74 6f 20 73 74 6f 72 65 | 20 61 6e 0d 6f 62 6a 65 |to store| an.obje|
|00005ea0| 63 74 27 73 20 28 77 72 | 69 74 61 62 6c 65 29 20 |ct's (wr|itable) |
|00005eb0| 61 74 74 72 69 62 75 74 | 65 73 3b 0d 0d 5c 69 74 |attribut|es;..\it|
|00005ec0| 65 6d 0d 5c 63 6f 64 65 | 7b 5c 76 61 72 7b 78 7d |em.\code|{\var{x}|
|00005ed0| 2e 5f 5f 6d 65 74 68 6f | 64 73 5f 5f 7d 20 6c 69 |.__metho|ds__} li|
|00005ee0| 73 74 73 20 74 68 65 20 | 6d 65 74 68 6f 64 73 20 |sts the |methods |
|00005ef0| 6f 66 20 6d 61 6e 79 20 | 62 75 69 6c 74 2d 69 6e |of many |built-in|
|00005f00| 20 6f 62 6a 65 63 74 20 | 74 79 70 65 73 2c 0d 65 | object |types,.e|
|00005f10| 2e 67 2e 2c 20 5c 63 6f | 64 65 7b 5b 5d 2e 5f 5f |.g., \co|de{[].__|
|00005f20| 6d 65 74 68 6f 64 73 5f | 5f 7d 20 69 73 0d 25 20 |methods_|_} is.% |
|00005f30| 58 58 58 4a 48 20 72 65 | 73 75 6c 74 73 20 69 6e |XXXJH re|sults in|
|00005f40| 3f 2c 20 79 69 65 6c 64 | 73 3f 2c 20 77 72 69 74 |?, yield|s?, writ|
|00005f50| 74 65 6e 20 64 6f 77 6e | 20 61 73 20 61 6e 20 65 |ten down| as an e|
|00005f60| 78 61 6d 70 6c 65 0d 5c | 63 6f 64 65 7b 5b 27 61 |xample.\|code{['a|
|00005f70| 70 70 65 6e 64 27 2c 20 | 27 63 6f 75 6e 74 27 2c |ppend', |'count',|
|00005f80| 20 27 69 6e 64 65 78 27 | 2c 20 27 69 6e 73 65 72 | 'index'|, 'inser|
|00005f90| 74 27 2c 20 27 72 65 6d | 6f 76 65 27 2c 20 27 72 |t', 'rem|ove', 'r|
|00005fa0| 65 76 65 72 73 65 27 2c | 20 27 73 6f 72 74 27 5d |everse',| 'sort']|
|00005fb0| 7d 3b 0d 0d 5c 69 74 65 | 6d 0d 5c 63 6f 64 65 7b |};..\ite|m.\code{|
|00005fc0| 5c 76 61 72 7b 78 7d 2e | 5f 5f 6d 65 6d 62 65 72 |\var{x}.|__member|
|00005fd0| 73 5f 5f 7d 20 6c 69 73 | 74 73 20 64 61 74 61 20 |s__} lis|ts data |
|00005fe0| 61 74 74 72 69 62 75 74 | 65 73 3b 0d 0d 5c 69 74 |attribut|es;..\it|
|00005ff0| 65 6d 0d 5c 63 6f 64 65 | 7b 5c 76 61 72 7b 78 7d |em.\code|{\var{x}|
|00006000| 2e 5f 5f 63 6c 61 73 73 | 5f 5f 7d 20 69 73 20 74 |.__class|__} is t|
|00006010| 68 65 20 63 6c 61 73 73 | 20 74 6f 20 77 68 69 63 |he class| to whic|
|00006020| 68 20 61 20 63 6c 61 73 | 73 20 69 6e 73 74 61 6e |h a clas|s instan|
|00006030| 63 65 20 62 65 6c 6f 6e | 67 73 3b 0d 0d 5c 69 74 |ce belon|gs;..\it|
|00006040| 65 6d 0d 5c 63 6f 64 65 | 7b 5c 76 61 72 7b 78 7d |em.\code|{\var{x}|
|00006050| 2e 5f 5f 62 61 73 65 73 | 5f 5f 7d 20 69 73 20 74 |.__bases|__} is t|
|00006060| 68 65 20 74 75 70 6c 65 | 20 6f 66 20 62 61 73 65 |he tuple| of base|
|00006070| 20 63 6c 61 73 73 65 73 | 20 6f 66 20 61 20 63 6c | classes| of a cl|
|00006080| 61 73 73 20 6f 62 6a 65 | 63 74 2e 0d 0d 5c 65 6e |ass obje|ct...\en|
|00006090| 64 7b 69 74 65 6d 69 7a | 65 7d 0d |d{itemiz|e}. |
+--------+-------------------------+-------------------------+--------+--------+